This is what I have until now but it doesnt compile include

This is what I have until now, but it doesn\'t compile

#include
#include
#include

void extract(char *s1, char *s2)
{
   int i = 0, j = 0, startIndex = 0, endIndex = 0;
  
   for(i; i < strlen(s1); i++)
   {
       if( s1[i] == \'w\' && s1[i+1] == \'w\' && s1[i+2] ==\'w\')
       {
           startIndex = i;
       }
      
       if( s1[i] == \'e\' && s1[i+1] == \'d\' && s1[i+2] ==\'u\')
       {
           endIndex = i+2;
       }
   }
  
  
   if( startIndex == 0 && endIndex == 0)
   {
       printf(\"Web address starting with www. and ending with .edu not found \");
   }
   else
   {
           for (startIndex; startIndex <= endIndex; startIndex ++)
           {
              
               s2[j] = s1[startIndex];
               j++;
           }          
   }
  
   s2[j] = \'\\0\';
          
}

void main()
{
   char input[1000];
   char output[1000];
  
   printf(\"Input: \");
   scanf(\"%s\", input);
  
   extract(input, output);
   printf(\"Output: \");
   printf(\"%s\", output);
}

I would really appreciate it!!! I will make sure to thumbs up. Thank you so much This code should be in C.

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 f.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 sl, char *s2); The function expects s 1 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. Please make sure it compiles with gcc-Wall. And show working output.

Solution

// The headers were not present!

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void extract(char *s1, char *s2)
{
int i = 0, j = 0, startIndex = 0, endIndex = 0;

for(i; i < strlen(s1); i++)
{
if( s1[i] == \'w\' && s1[i+1] == \'w\' && s1[i+2] ==\'w\')
{
startIndex = i;
}

if( s1[i] == \'e\' && s1[i+1] == \'d\' && s1[i+2] ==\'u\')
{
endIndex = i+2;
}
}


if( startIndex == 0 && endIndex == 0)
{
printf(\"Web address starting with www. and ending with .edu not found \");
}
else
{
for (startIndex; startIndex <= endIndex; startIndex ++)
{

s2[j] = s1[startIndex];
j++;
}
}

s2[j] = \'\\0\';

}
int main() // main should return int
{
char input[1000];
char output[1000];

printf(\"Input: \");
scanf(\"%s\", input);

extract(input, output);
printf(\"Output: \");
printf(\"%s\", output);
}

This is what I have until now, but it doesn\'t compile #include #include #include void extract(char *s1, char *s2) { int i = 0, j = 0, startIndex = 0, endIndex
This is what I have until now, but it doesn\'t compile #include #include #include void extract(char *s1, char *s2) { int i = 0, j = 0, startIndex = 0, endIndex

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site