Quote (bakalolo @ Oct 5 2013 12:23am)
this doesnt help me if i dont know why im getting a non zero
i already know strcmp is not returning zero
i'm no C expert, but your buffer size of 20 seems suspicious to me since you're comparing it to something with size 1. how do you determine how many characters you're reading in? either you're terminating after 20 characters or you're signaling fgets to terminate early somehow. try running strlen on the input and strlen of "y" and see what you get. i suspect you're telling fgets to stop after "y" by pressing the enter button, which might produce a newline character. so strlen(str3) = 2 from y\n (or possible 3 if y\r\n) instead of 1 that you expect.
but if strlen(str3) is 1 and strlen("y") is 1 and printing them both out look the same, then print out the ascii/unicode/binary. keep debugging until you're 100% sure they're the same. if it comes to that point, see if maybe there's another comparison function to use. and if you're still not making progress, i'm out of ideas. then wait for someone else with more C experience to point out the problem.
/edit: and of course, try out strcmp("y", "y") and make sure that returns what you expect.
This post was edited by carteblanche on Oct 4 2013 11:03pm