Question: 1. (60 points) Write a program to extract Web addresses starting with www. and ending with .edu. The program displays Web address contained in the

1. (60 points) Write a 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 lecture notes. 2. (40 points) Write a program that finds either the largest or smallest of the ten numbers as command-line arguments. With l for largest and s for smallest number, if the user enters an invalid option, the program should display an error message. Example runs of the program: ./find_largest_smallest l 5 2 92 424 53 42 8 12 23 41 output: The largest number is 424 ./find_largest_smallest s 5 2 92 424 53 42 8 12 23 41 output: The smallest number is 2 1) Name your program numbers.c. 2) Use atoi function in to convert a string to integer form. 3) Generate the executable as find_largest_smallest.

gcc Wall o find_largest_smallest numbers.c

1)#include #include #include #define STR_LEN 1000 void extract(char *s1, char *s2); int read_line(char *str, int n); int main(void) { char input[STR_LEN+1]; char output[STR_LEN+1]; int b=0; while(!b) { printf("Enter the Web Addresses or 'Quit': "); scanf("%s", input); if (strstr(input,"Quit")!=NULL) { break; } read_line(input, STR_LEN); extract(input, output); printf("%s",output); } return 0; } void extract(char *s1, char *s2) { if ((strstr(s1,"www.")!=NULL) && (strstr(s1,".edu")!=NULL)) { strcpy(s2, "www."); int c=1; char *p; for (p=s1+1; p

2)#include #include #include int main(int argc, char *argv[]) { int l=-1; /* apparently i am initializing wrong because my largest value is correct and my smallest is wrong. int i; int s=1;*/ if(strcmp(argv[1],"-l")==0) { for(i=1;il) { l=atoi(argv[i]); } } printf("The Largest Number is %d",l); } else if(strcmp(argv[1],"-s")==0) { for(i=1;i

can anybody help out on both of these to fix my errors? would be super cool! thax in advance

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!