C special character display
To display special characters in C, you can use escape sequences. Escape sequences are character sequences that represent special characters and cannot be directly represented in a string. Here are some commonly used escape sequences in C:
- \n - newline character
- \t - tab character
- \r - carriage return
- \' - single quote
- \" - double quote
- \ - backslash
For example, if you want to display a new line character, you can use the escape sequence "\n" in a string. Here's an example:
#include <stdio.h>
int main() {
printf("Hello\nWorld");
return 0;
}
Output:
Hello
World
Similarly, if you want to display a tab character, you can use the escape sequence "\t". Here's an example:
#include <stdio.h>
int main() {
printf("Name:\tJohn");
return 0;
}
Output:
Name: John
You can use these escape sequences to display other special characters in C as well.