Reading In A String and comparing it C
Posted
by ahref
on Stack Overflow
See other posts from Stack Overflow
or by ahref
Published on 2010-04-05T00:19:18Z
Indexed on
2010/04/05
0:23 UTC
Read the original article
Hit count: 566
Im trying to create a C based string menu where a user inputs a command and then a block of code runs.
Whatever i do the conditional is never true:
char *input= "";
fgets(input, 50, stdin);
printf("%s",input);
printf("%d",strcmp( input,"arrive\0"));
if(strcmp( input,"arrive\0")==0){....
Im fairly new to c and am finding strings really annoying.
What am i doing wrong?
© Stack Overflow or respective owner