If you have any query feel free to chat us!
Happy Coding! Happy Learning!
In the C programming language, an escape sequence is a combination of characters that represents a special character or symbol that is not represented by a single character. An escape sequence begins with a backslash \ followed by another character.
Here are some common escape sequences used in C:
\n : newline\r : carriage return\t : horizontal tab\v : vertical tab\b : backspace\f : form feed\\ : backslash\' : single quote\" : double quoteFor example, the following code will print "Hello, World!" on two lines:
Copy code
printf("Hello,\nWorld!");
This will output:
Copy code
Hello,
World!
Another example is to use a single quote or double quote inside a string, you can use escape sequence to specify them.
Copy code
printf("This string contains a single quote: '");
printf("This string contains a double quote: \"");
This will output:
Copy code
This string contains a single quote: '
This string contains a double quote: "
Escape sequences are also used to represent non-printable characters and special characters that are not present on the keyboard.
It's important to note that some escape sequences, such as \n and \t, are interpreted by the compiler and affect the layout of the output, while others, such as \\ and \", are used to represent special characters within strings.
Start the conversation!
Be the first to share your thoughts
Quick answers to common questions about our courses, quizzes, and learning platform
Didn't find what you're looking for?
Contact Support