What does this mean?
while the input data is not a new line? or a / character n?
Printable View
What does this mean?
while the input data is not a new line? or a / character n?
'/n' will cause a compilation error.
Within a character constant or a string literal, character sequences starting with a \ (backslash, not forward slash) are called escape sequences. The escape sequence \n (backslash followed by an n) represents a newline. So, '\n' is a single character, and "\n" is a string literal consisting of two characters, one with value '\n' and the other zero.
Note that \n is not the only escape sequence. Any basic C text will describe them, or (noting that you should sanity-check most things you find on the internet, including this post) Google for "C escape sequence"
This is, in all likelyhood, a programmer mistake (she must have wanted a backslash and the absence of the semicolon).
As it is, it's either an infinite loop or a do nothing statement depending on the value of batting_record.
If batting_record has a value of '/n' (a multi-character constant which value is implementation defined) it is a do nothing statement
if batting_record has a different value it is an infinite loop: doing nothing (empty body) does not change the value and all it does (over and over and over) is compare the values.
This code, on the other hand, keeps reading characters from the standard input stream up to and including a newline character. Note that this code does not check for errors, as a proper code should do.Code:int batting_record;
while (batting_record != '\n') {
batting_record = getchar();
}