Why is it when I run the sub function programe is prefrectly fine but when I impliment it to the main programe it simply skip the input part... the fgets command....
here is the programe:
Code:
main()
{
char str[100];
int ch;
printf ("Enter the String :");
fgets (str, sizeof str, stdin);
printf ("\n");
printf ("1/ Count Number of Characters In String.\n");
printf ("2/ Count Number of Words In String.\n");
.......
void looksub (char str[])
{
char substr[100];
char *p;
printf ("Enter the substring you want to find: ");
fgets (substr, sizeof substr, stdin);
p = strchr(substr, '\n');
if(p) *p = '\0';
if (strstr(str, substr))
printf ("The substring '%s' is found !!!", substr);
else
printf ("The substring '%s' is not found!!!", substr);
}
When come to the looksub function, it straight away go to the printf statement, without allowing me to key in my option.. Why !!!
Here is an attachment of my file....