nhờ các anh coi giùm bài này. biên dich không bị lỗi nhưng bị lỗi ở kết quả.
Code:
/*finding ocurrences of one string in another without case-sensitive*/
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h> /*classification header file*/
int main()
{
char substring[40];
char text[100];
printf("Please enter the string to be searched (less than 100 characters):\n");
fgets(text,sizeof(text),stdin);
printf("Enter the string sought:\n");
fgets(substring,sizeof(substring),stdin);
/*overwrite the newline character in each string*/
text[strlen(text)-1] ='\0';
text[strlen(substring)-1]='\0';
printf("\nFirst string entered: %s\n",text);
printf("\nSecond string enterd: %s\n", substring);
/*convert both strings to uppercase*/
for(int i=0;i<strlen(text);i++)
text[i]=toupper(text[i]);
for(i=0;i<strlen(substring);i++)
substring[i]=toupper(substring[i]);
printf("The second string %s found in the first string.",
( strstr(text,substring) == NULL )? "was not":"was");
getch();
return 0;
}