#include<stdio.h>
#include<string.h>
int main()
{
char strg1[];
char strg2[] = "football"
printf("Enter first string: ");
gets(strg1);
if(strcmp(strg1, strg2)==0)
{
printf("\nEqual");
}
else
{
printf("\nNot Equal");
}
return 0;
}
I'm getting a string from the user as input and I want to compare it with a ready-made string I have, whether it's equal or not. When I try with strcmp, they are not equal. When I try with strncmp, for example, user footballABC wrote my string football is still equal because with strncmp it is 8 characters. I've limited it. Is there a solution?