tags:

views:

103

answers:

4

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?

+2  A: 

\b is backspace (ASCII 0x8). You don't need an escape for regular space (ASCII 0x20). You can just use ' '.

Matthew Flaschen
+6  A: 

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

Here's a list of escape sequences for reference.

GMan
Ah, thanks bud.
MW2000
A: 

Hi,

'\b' is backspace, and you don't really need an escape sequence for blanks as ' ' will do just fine.

Joseph Paterson
+1  A: 

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.

caf