Untitled

                Never    
C
       
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#define MAX 1000

int main()
{
  char *str1, *str2;
  char msg1[MAX], msg2[MAX];
  char* loc;


  str1 = msg1;
  str2 = msg2;
  printf("Please enter the first string.");
  //msg1[1] ='\0';
  scanf("%s", msg1);
  //gets(msg1);
  printf("Good, now please enter the second string.");
  //msg2[1] ='\0';
  scanf("%s", msg2);
  gets(msg2);
  int count = 0;

while(*str1!= '\0')
{

  //str1[sizeof(msg1)] = '\0';
  printf("\n\n[%s]", str1);



   if((loc = strstr(str1, str2)) != NULL && strcmp(loc, str2) == 0)
  {
    printf("The value of the loc variable after assigning str1 and str2 is %s", loc);
    printf("\n\nthe string %s is on location %d inside of %s on line %d",str2,  str1-str2-MAX, str1, count);
    printf("\nstrlen is %d", strlen(str2));
    str1 += strlen(str2);
    if(*str1 == '\n')
      count++;
    //loc = 0;
  }

  else if(*str1 == '\n')
  {
    count++;
  }
  printf("\nloc is %s", loc);
  printf("\ncount is %d", count);

  str1++;


}

}

Raw Text