c - Code not reaching statements using fgets? -


i have written code uses fgets function multiple conditions call other functions within code, namely amethod , bmethod.

int main(void) { char buffer[1024]; while (fgets(buffer, 1024, stdin)) {     if ((strcasecmp(buffer,"a")) == 0) {         amethod();         }     if ((strcasecmp(buffer, "b")) == 0) {         bmethod();         }     } } 

i'm not sure why doesn't reach if statements. great, thankyou.

if in doubt, print out:

int main(void) { char buffer[1024]; while (fgets(buffer, 1024, stdin)) {     fprintf(stderr, "buffer [%s]\n", buffer);   /* <==== */     if ((strcasecmp(buffer,"a")) == 0) {         amethod();         }     if ((strcasecmp(buffer, "b")) == 0) {         bmethod();         }     } } 

you find lot of errors way.


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -