strcmp on a line read with fgets

后端 未结 6 1163
你的背包
你的背包 2020-11-22 11:56

I\'m trying to compare two strings. One stored in a file, the other retrieved from the user (stdin).

Here is a sample program:

int main()
{
    char          


        
6条回答
  •  孤城傲影
    2020-11-22 12:23

    fgets appends the newline to the string, so you'll end up with bob\n\0 which isn't the same as bob\0.

提交回复
热议问题