Question
Write a C program to extract Web addresses starting with www. and ending with .edu. The program displays Web address contained in the input entered
Write a C program to extract Web addresses starting with www. and ending with .edu. The program displays Web address contained in the input entered by the user. If the input does not contain a web address that starts with www. and ends with .edu, the program should display a message that indicates such a web address cannot be found.
Input: http://www.usf.edu/admission
Output: www.usf.edu
Input: https://www.facebook.com/
Output: Web address starting with www. and ending with .edu not found Your program should include the following function: void extract(char *s1, char *s2); The function expects s1 to point to a string containing the input as a string and stores the output to the string pointed by s2.
1) Name your program extract.c.
2) Assume input is no longer than 1000 characters. Assume the input contains no more than one qualifying web address.
3) The extract 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.
4) To read a line of text, use the read_line function (the pointer version) in the -down-
int read_line(char *str, int n) {
int ch, 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
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