I'm writing some code to read a text file on stdin using fgets which compares two adjacent lines from the 1st and 2nd all the way to the 2nd last and last for equality. My problem is that it works all the way till the final case.
For example let's say our text file contains the following:
one
two
three
three
four
four
When I use strcmp on the last 2 lines, -1 is returned and when I use strlen on both 'four's, I got a 5 and a 6 respectively.
So where are the extra characters coming from and how can I overcome that so I can do a proper string comparison and have strcmp return a 0? Any tips would be great!