1) when you use “r” - opening in normal text format
there is a difference in the way C and other (DOS in my example) represents the End-of-LINE (EOL). In C, the EOL is signalled by a single character, the \n the Newlinefeed. but in DOS, the EOL is signalled by 2 characters, combination of \r-Carriage Return and \n-Newlinefeed.
so if you write a C program to count total number of characters in a file and say, for example, result is 100 (for 10 lines in a file), so when you run it in C, the result will be 100 but when you run the program form DOS, the result will be 110 (10 \r for 10 lines) because it will convert all the \n to \r\n.
2) when using “rb” - opening file in Binary format
but this is the not the case with Binary mode. when reading from disk, it will not convert the \r\ns to \ns. here if you run the program through C IDE, the result will be 110 as shown by DOS also and not 100 because of additional \rs.