Character and String Manipulation Flashcards
is usually declared as an array of char.
C-String
A valid C string requires
the presence of a terminating “null
character” (a character with ASCII value 0, usually represented by the character literal ‘\0’).
declares a set of functions to
work with C-style string
The C++ <cstring> header file</cstring>
copies character string from source to destination
strcpy
copies specified bytes of characters from source to destination.
strncpy
appends a copy of a string to the end of another string
strcat
appends a specified number of characters of a string to the end of another string
strncat
returns length of given string
strlen
compares two null terminating string. The
comparison is done lexicographically.
strcmp
compares a specified number of characters of two null terminating strings. The comparison is done lexicographically.
strncmp
can be used to read a line of input
and place the string of characters on that line into a C-string variable.
getline
allows your program to read in one character
of input and store it in a variable of type char
get function
This function member is analogous to the member function get except that it is used for output rather than input.
put function
allows your program to output one
character
put function
This header declares a set of functions to classify and transform individual characters.
C++ <cctype></cctype>
Convert uppercase letters to lowercase
tolower
Convert lowercase letter to uppercase
toupper
Check if character is uppercase letter
isupper
Check if character is lowercase letter
islower
Check if character is alphabetic
isalpha
Check if character is decimal digit
isdigit
Check if character is alphanumeric
isalnum
Check if character is a white space
Isspace
Check if character is a punctuation character
ispunct