strcmp on a line read with fgets

后端 未结 6 1116
你的背包
你的背包 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:06

    Because fgets is embededing the newline character into the variable targetName. This is throwing off the comparison.

提交回复
热议问题