Thursday, January 16, 2025
HomeProgrammingWhat are Carriage Return, Linefeed, and Form Feed?

What are Carriage Return, Linefeed, and Form Feed?

What are Carriage Return, Linefeed, and Form Feed?

Carriage return (CR), linefeed (LF), and form feed (FF) are control characters used in text formatting and printing, originating from the early days of computing and typewriters. Here’s what each represents:

Carriage Return (CR)

  • Symbol: \r
  • Function: Moves the cursor or print head to the start of the current line without advancing to the next line.
  • Modern Use: Historically used in typewriters; in computing, it serves as a line-ending character in systems like classic Mac OS.
See also  How do I update Node.js?

Linefeed (LF)

  • Symbol: \n
  • Function: Advances the cursor or print head to the next line without returning to the start of the line.
  • Modern Use: Common in UNIX-based systems (like Linux and macOS) to indicate the end of a line in text files.

Form Feed (FF)

  • Symbol: \f
  • Function: Advances the cursor or print head to the start of the next page or a defined section.
  • Modern Use: Rarely used today but may appear in some printer control sequences or specialized text processing.
See also  Program to Convert cm to Feet and Inches

Key Differences

Character Symbol Purpose
Carriage Return \r Returns to the beginning of the current line.
Linefeed \n Moves to the next line.
Form Feed \f Moves to the start of the next page.

Combining CR and LF

In Windows systems, both CR and LF (\r\n) are used together to mark the end of a line. This ensures compatibility with older software and hardware.

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