Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the escape sequence for blanks in C?

Tags:

I'm writing a program to count blanks, tabs, and newlines. I remember what the escape sequence for tabs and newlines are, but what about blanks? \b? Or is that backspace?

like image 559
MW2000 Avatar asked Jul 21 '10 23:07

MW2000


People also ask

What is the use of '\ t escape sequence?

\t (Horizontal Tab) This is the escape sequence for the horizontal tab. Words that come after '\t' will be pushed in the same line leaving some spaces. Its ASCII value is 009.

What is the '\ n escape character?

In particular, the \n escape sequence represents the newline character. A \n in a printf format string tells awk to start printing output at the beginning of a newline.

Which escape character can be used to tab space in C?

\xhh (Hexadecimal number) – We use it to represent a hexadecimal number. \v (Vertical tab) \b (Backspace) \e (Escape character)


2 Answers

You mean "blanks" like in "a b"? That's a space: ' '.

Here's a list of escape sequences for reference.

like image 177
GManNickG Avatar answered Oct 12 '22 01:10

GManNickG


If you want to check if a character is whitespace, you can use the isspace() function from <ctype.h>. In the default C locale, it checks for space, tab, form feed, newline, carriage return and vertical tab.

like image 42
caf Avatar answered Oct 12 '22 01:10

caf