norman's blog

Notes of an amnesiac.
Never stop thinking.
Find an aesthetic description.

Tuesday, June 2, 2009

string and character

Type of String and Character

Characters are used to represent characters in the execution character set, which have the type char.
The execution character set is not necessarily the same as the source character set used for writing C programs. The execution character set includes all characters in the source character set as well as the null character, newline character, backspace, horizontal tab, vertical tab, carriage return, and escape sequences.

Strings are used to represent a sequence of characters which, taken together, form a null-terminated string. Strings have type array of char.This means that a string is an array with elements of type char. The number of elements in the array is equal to the number of characters in the string plus one for the terminating null character('\0').

Single Quotation and Double Quotation

A "character" is formed by enclosing a single character within single quotation marks (' ').
A "string" is a sequence of characters enclosed in double quotation marks (" ").

Representation of Characters and Escape Sequences

For common printable characters, a direct WYSIWYG representation is applicable. For instance: 'A' stands for the character A. For unprintable characters and printable characters with special meanings, escape sequences are used. Character combinations consisting of a backslash (\) followed by a letter or by a combination of digits are called "escape sequences". Actually, all characters can be represented by Oct/Hex notation of escape sequences.
\a Bell (alert)
\b Backspace
\f Formfeed
\n New line
\r Carriage return
\t Horizontal tab
r\v Vertical tab
\' Single quotation mark
\ " Double quotation mark
\\ Backslash
\? Literal question mark
\ ooo ASCII character in octal notation
\x hh ASCII character in hexadecimal notation
\x hhhh Unicode character in hexadecimal notation if this escape sequence is used in a wide-character constant or a Unicode string literal. For example, WCHAR f = L'\x4e00' or WCHAR b[] = L"The Chinese character for one is \x4e00".

See MSDN Reference

Standard C String and Character Functions

Check "string.h" and "stdlib.h".
See Functions list.
See string.h.
See stdlib.h.

ASCII Code

ASCII includes definitions for 128 characters: 33 are non-printing, mostly obsolete control characters that affect how text is processed;[6] 94 are printable characters, and the space is considered an invisible graphic.
See wiki.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home