In computing, a newline character, also known as a line ending, end of line (EOL), or line break, is a special character or sequence of characters signifying the end of a line of text. The actual codes representing a newline character vary across operating systems, which can be a problem when exchanging text files between systems with different newline character representations.
The C programming language provides the escape sequences '\n' (newline character) and '\r' (carriage return). However, these are not required to be equivalent to the ASCII LF andĀ CR control characters. The C standard only guarantees two things:
- Each of these escape sequences maps to a unique implementation-defined number that can be stored in a single char value.
- When writing a file in text mode, '\n' is transparently translated to the native newline character sequence used by the system, which may be longer than one character. When reading in text mode, the native newline character sequence is translated back to '\n'. In binary mode, no translation is performed, and the internal representation produced by'\n' is output directly.
Use of Newline Character
[message_box title=”Program ” color=”red”]
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*Use Newline Character in C programming */
/* Written by Utpal Chaudhary*/
/* Student of LD College of Engineering, Ahmedabad, Gujarat.*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
void main()
{
printf (“Hello !! Friends ,\n How are you ? “);Ā /* Here, n (\n) is newline character*/
}
[/message_box]
[message_box title=”Output” color=”red”]
Hello !! Friends
How are you?
[/message_box]