Use of Newline Character : C Language

0
4220
Newline Character
newline character

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:
  1. Each of these escape sequences maps to a unique implementation-defined number that can be stored in a single char value.
  2. 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]

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments