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 8718691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:36:25+00:00 2026-06-13T06:36:25+00:00

The compiler for normal string literal with valid escape sequence like \n , \t

  • 0

The compiler for normal string literal with valid escape sequence like \n,\t compiles without any error.

But the moment I use invalid escape characters like \s,\w the compiler shows an error.Yes,We can avoid the error by using verbatim string or escaping it with \\ but my question is

Do compiler validates the string literals for valid escape characters and if so is that it’s only purpose!

  • 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-06-13T06:36:26+00:00Added an answer on June 13, 2026 at 6:36 am

    Do compiler validates the string literals for valid escape characters

    Yes, it obviously does, that’s why you get the error messages.

    and if so is that it’s only purpose!

    I don’t really understand this question. I am assuming you are wondering why the compiler doesn’t simply accept invalid escape sequences and treats them verbatim. This would indeed be a possibility but it would render the interpretation of string literals slightly inconsistent: \x would mean different things depending on the actual value of x.

    At the very least, there’s no disadvantage in C#’s strict checking of escape sequence validity. And maybe it avoids errors due to typos and confusions arising from different numbers of consecutive backslashes.

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

Sidebar

Related Questions

I have seen code like this: struct failed_login_res { string errorMsg<>; unsigned int error;
I'm having some GLSL problems. When I just use normal VBO's without the shaders,
Normaly MinGW (GCC C Compiler) recompiles only files that have beeen changed. But I
The compiler doesn't know where stat.h is? Error: c:\Projects\ADC_HCI\mongoose.c(745) : error C2079: 'st' uses
The compiler (VC8) error is: error C2680: 'std::_Tree<_Traits>::iterator' : invalid target type for dynamic_cast
The compiler complains about this code: HashMap<String,int> userName2ind = new HashMap<String,int>(); for (int i=0;
g++ compiler gives this error: expected `;' before 'it' template <typename T> class myList
I don't really know much about the internals of compiler and JIT optimizations, but
I have a CUDA kernel which I'm compiling to a cubin file without any
The code below compiles fine with VS2010 but fails to compile with gcc 4.6.1:

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.