开发者

why comparing 2 equal strings(printing on screen) with strcmp function give wrong answer?

I tried to compare 2 IP Addresses stored in 2 character arrays. I get the first IP Add char array from socket and the seco开发者_JS百科nd IP Add char array from text file. When I use strcmp function, I got a non-zero value(which means 2 strings are not equal) although when I tried to printf on the screen , they are equal. Any idea about my prob?


Probably the problem is a special character like '\n', '\r', ... in your char array (from text file). Try to delete them ;-)

How to remove a carriage return from a string in C?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜