String / Character Functions

What are String / Character Functions in C++?

Explanation

Standard Function Library has a numerous set of string and character handling functions. The string function operate on the null-terminated arrays. The header file required for string function is "<cstring.h> and for character use the header file "<cctype>".

Parameters passed to character functions are integers that are lower order bytes. These function convert the arguments to unsigned char, that will converted to integers at the time of call. The array overflow has to be taken care by the coders to prevent any issues with C++ program.

Following table lists few String and Character functions of C++ Standard function Library.
Name Description
isalnum() Checks if the given argument is alphanumeric character.
isalpha() Checks if the given argument is an alphabet.
isdigit() Checks if the given argument is a digit(0-9)
ispunct() Checks if the given argument is a punctuation character
iscntrl() Checks if the given argument is a control character
isspace() Checks if the given argument is a space character
isupper() Checks if the given argument is a uppercase alphabets
isgraph() Checks if the given argument is a graphical character.
islower() Checks if the given argument is a lowercase alphabets
isprint () Checks if the given argument is a printable character
isxdigit() Checks if the given argument is a hexadecimal digit
strcpy() Copies the content of a string to another.
strchr() Returns a pointer value for the first occurrence of character.
strcat() Appends a copy of the source string to the destination string
strcoll()
strncmp() Compares two strings lexicographically until the characters differ or a null terminated string is encountered
strncpy() Copies upto the characters specified in the "count" from string 2 to string 1
strpbrk() Returns a pointer to the first character in string that matches any character another string.
strrchr() Returns the last occurrence of a character in the string.
strstr() Returns a pointer to the first occurence of string2 in string1.
strspn() Returns the initial subtring of string1 which consists only of characters contained in string2.
strtok() Returns a pointer to next token in the string.
strxfrm() Transforms string2, so that it can be used by "strcmp()".
strerror() Returns the value of errnum as a string a string describing the error.
strlen() Returns the length of a string.
strcspn() Returns the index of the first character in the string1 that matches any of the characters in string2.
tolower() Returns the lowercase of the parameter.
toupper() Returns the uppercase of the parameter.
memset() Sets the specified number of bytes of memory pointed by the pointer to the specified value.
memchr() Searches the array for first occurence of a character.
memmove() Copies the specified count of characters from the an array to another.
memcpy() Copies the specified number of characters from the array2 to array1.
memcmp() Compares the specified number of characters from the array1 to array2.


Following table lists few String and Character functions of C++ Standard function Library.

C++ Tutorial


Ask Questions

Ask Question