Question
Write a program to find the domain name of an email address if the domain name ends with .edu. The program displays do main that
Write a program to find the domain name of an email address if the domain name ends with .edu. The program displays do
main 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.
Your program should include the following function:
int d_main(char *s1, char *s2);
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.
Assume input is no longer than 1000 characters. Assume the input contains no more than one qualifying web address.
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.
To read a line of text, use the
read_line function below:
int read_line(char *str, int n)
{
int ch;
int i = 0;
while ((ch = getchar()) != ' '){
if (i < n)
{
*str++= ch;
i++;
}
}
*str = '\0';
return i;
}/
input: nintendo123@ncy.edu
output: ncy.edu
Do not use any malloc function or any other function besides given in the question it is basic string program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started