Saturday, January 11, 2025
HomeProgrammingWhat exactly is r in C language?

What exactly is \r in C language?

In C, \r is a carriage return character, which moves the cursor to the beginning of the current line without advancing to the next line. It is useful in situations where you want to overwrite existing text on the same line. When \r is encountered, it resets the cursor position to the start of the line, allowing new text to overwrite what was previously displayed.

See also  What is a cell in Excel - javatpoint

Example:

c
#include <stdio.h>

int main() {
printf("Hello\rWorld");
return 0;
}

This will print “World” by overwriting “Hello” on the same line. The effect varies by terminal.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x