OKPEDIA C EN

How to wrap in C

To do a carriage return in C, use the special character newline \n inside a string.

Example

In C language, the printf statement does not wrap automatically.

printf("Hello");
printf("World");

The second printf() prints on the same line as the first printf().

HelloWorld

To write on two different lines, add the \n (newline) character to the end of the first string.

The special character \n performs a carriage return.

printf("Hello \n");
printf("World");

The output result on the screen is as follows

Hello
World

https://how.okpedia.org/en/c/how-to-wrap-in-c


Report an error or share a suggestion to enhance this page


C Language


FacebookTwitterLinkedinLinkedin