using the integer difference in strcmp in c programming
i have this below program
#include <stdio.h>
#include <stdlib.h>
int main()
{
char text1[30],text2[30];
int diff;
puts("Enter text1:");
fgets(text1,30,stdin);
puts("Enter text2:");
fgets(text2,30,stdin);
diff=strcmp(text1,text2);
printf("Difference between %s and %s is %d",text1,text2,diff);
}
if i give text1 as inputtext and text2 as differencetext , then the
difference should be 5 , but i am getting as 1 for different inputs , i am
not sure where i am going wrong.
No comments:
Post a Comment