Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C(89). A fashion retailer has decided to provide discount codes to teachers and students during a promotional event. The first step is to verify

Using C(89). A fashion retailer has decided to provide discount codes to teachers and students during a promotional event. The first step is to verify the teacher/student status of people requesting discount code by their email addresses. They will check if the email addresses end with ".edu" and find the domain name if it does before further verification. Write a program to find the domain name of an email address if the domain name ends with .edu. The program displays domain that ends with edu. If the input does not contain an email address that ends with .edu, the program should display a message that indicates it is not a valid email address for the discount code.

Example input/output:

Input: jennifer23@nyu.edu

Output: nyu.edu

Input: joeW19@mail.usf.edu

Output: mail.usf.edu

Input: johnA@facebook.com/

Output: Not a valid email address for the discount code

Your program should include the following function: int find_domain(char *s1, char *s2);

NOTE:

1) The find_domain function expects s1 to point to a string containing the input for an email address as a string and stores the domain to the string pointed by s2. If the email address does not end with .edu, s2 should contain an empty string. An empty string is a valid string with no characters except the null character. The function returns 1 if the email addresses ends with .edu in the domain, and returns 0 otherwise.

2) The find_domain function should use pointer arithmetic (instead of array subscripting). In other words, eliminate the loop index variables and all use of the [] operator in the function.

3) To read a line of text, use the read_line function (the pointer version):

}

int read_line(char *str, int n)

{

int ch; int i = 0;

while ((ch = getchar()) != ' ')

{ if (i < n)

{ *str++= ch;

i++;

}

}

* str = '\0'; /* terminates string */

return i; /* number of characters stored */

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Privacy In Statistical Databases International Conference Psd 2022 Paris France September 21 23 2022 Proceedings Lncs 13463

Authors: Josep Domingo-Ferrer ,Maryline Laurent

1st Edition

3031139445, 978-3031139444

More Books

Students also viewed these Databases questions

Question

Analyse the various techniques of training and learning.

Answered: 1 week ago