What’s up with Java’s “%n” in printf?

From a quick google: There is also one specifier that doesn’t correspond to an argument. It is “%n” which outputs a line break. A “\n” can also be used in some cases, but since “%n” always outputs the correct platform-specific line separator, it is portable across platforms whereas”\n” is not. Please refer https://docs.oracle.com/javase/tutorial/java/data/numberformat.html Original source

Reading \r (carriage return) vs \n (newline) from console with getc?

\n is the newline character, while \r is the carriage return. They differ in what uses them. Windows uses \r\n to signify the enter key was pressed, while Linux and Unix use \n to signify that the enter key was pressed. Thus, I’d always use \n because it’s used by all; and if (x == ‘\n’) is the proper way to test character equality.