I was making a program to search a track from a list of tracks by getting an input string from user.
#include<stdio.h>
#include<string.h>
char tracks[][80] = {
"I left my heart in harvard med school",
"Newark, newark - a wonderful town",
"Dancing with a dork",
"From here to maternity",
"The girl from Iwo Jima",
};
void find_track(char search_for[])
{
int i, m = 0;
for(i = 0; i<5; i++)
{
the control reaches upto this line of code
m = strstr(tracks[i], search_for);
if(m)
{
printf("Track%i : '%s' \n", i, tracks[i]);
}
}
}
strstr() returns 0
int main()
{
char search_for[80];
printf("Search for : ");
fflush(stdin);
fgets(search_for, 80, stdin);
find_track(search_for);
return 0 ;
}