I'm trying to check if the line read from stdin begins with "login:" but strcmp does not seem to work.
char s1[20], s2[20];
fgets(s1, 20, stdin);
strncpy(s2,s1,6);
strcmp(s2, "login:");
if( strcmp(s2, "login:") == 0)
printf("s2 = \"login:\"\n");
else
printf("s2 != \"login:\"\n");
I don't care what comes after "login:", i just want to make sure that's how the command is given. What am i doing wrong?