Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6983465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:25:20+00:00 2026-05-27T18:25:20+00:00

I just wanted to know how backslash escape sequences are implemented in compilers? If

  • 0

I just wanted to know how backslash escape sequences are implemented in compilers?
If we write “\n” in a string, how does a compiler come to replace it with a new line character? How does a compiler come to replace “\b” with a backspace character?

I ask because I wrote the code:

#include<stdio.h>
main()
{
    printf("Hello \c");
}

The output was:

Hello 
Exited: ExitFailure 7 

I ran it in codepad, I was going through KnR book question number 1.2.

Thanks in Advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T18:25:20+00:00Added an answer on May 27, 2026 at 6:25 pm

    To understand this, you have to understand a little bit about how compilers work in general. The first step which compilers generally undertake is called lexical analysis (or lexing for short). Lexical analysis is when the compiler takes the input code and breaks it into pieces which it can recognize. To do this, it usually uses regular expressions to recognize the different pieces. One of the pieces it recognizes is a string literal, which is a quoted string like "Hello". The regular expression for a string literal usually looks like "([^\"]|\"|\\|\n|\b)*". Which, in English, means a list of characters which starts with a double quote and ends with a double quote, and in between has either 1) any character which isn’t a double quote or a backslash 2) a backslash and then a double quote 3) a backslash and then another backslash 4) a backslash and then an n 5) a backslash and then a b. This middle pattern is repeated zero or more times. (Note: in real compilers, the list of characters which can occur after the back-slash is generally longer). Looking for this pattern allows it to find string literals.

    Then, once the string literal has been identified, to find out what string to actually put in memory, it has to do a second layer of processing which is to go through the string literal and handle the backslashes. It just reads from the start to the end, looking for backslash sequences. Each of the backslash sequences is replaced with a different character. \" becomes ". \\ becomes \. \n becomes a newline. \b becomes a backspace character, and so forth. To figure out which to put where, it just uses a table which shows what to put in place for that sequence.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wanted to know. What are the differences between java.util.Properties Vs java.util.HashMap<String, String> ?
I just wanted to know more about analytics. I am new to this thing.
Just wanted to know if serializing a string is equivalent to getting its bytes?
I just wanted to know how does personalization of a web page happen? How
I'm new to OOP and just wanted to know, within a class, when should
I am a bit new to MySQL and just wanted to know what is
Just wanted to know that does Visual web Developer 2010 [Free tool] contains MVC
Just wanted to know if it is possible to disallow the whole site for
Just wanted to know if anyone is really using Objects and Collections in Oracle
Just wanted to know if there is a big chance to inject SQL While

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.