From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Specifying characters and strings

Specifying characters and strings - C Tutorial

From the course: Complete Guide to C Programming Foundations

Specifying characters and strings

- [Instructor] To declare a single character literal in your code, sit the character between a pair of single quotes as shown here, 'A' '.' '3'. For characters, you can't type like enter and tab, use an escape sequence literal. These characters, and yes, they're interpreted as single characters, start with a backslash and then a special character. You can also escape specific values as a single character, such as hexadecimal value 41, which is shown as /x41. Though multiple characters are used, this escape sequence remains a single character value. This list shows common escape sequences for single characters. The new line is one escape sequence you see most often. It inserts the enter key press into a string, or it's used as a single character. If you want to specify a single quote character, you use \" within single quotes. And string literals with double quotes inside must have the internal double quote character escaped. This code prompts for single character input. Escape…

Contents