String Functions

Function Declaration Description Header File
int atoi(const chara[]); Converts a string of characters to an integer. cstdlib
int stoi(const string) Converts a STL string object to an integer. C++11 and higher. string
long atol(const chara[]); Converts a string of characters to a long integer. cstdlib
long stol(const string) Converts a STL string object to a long. C++11 and higher. string
double atof(const char a[]); Converts a string of characters to a double. cstdlib1
strcat(String_Variable, String_Expression); Appends the value of the String_Expression to the end of the string in the String_Variable. cstring
strcmp(String_Exp1, String_Exp2) Returns true if the values of the two string expressions are different; otherwise, returns false.2 cstring
strcpy(String_Variable, String_Expression); Changes the value of the String_Variable to the value of the String_Expression. cstring
strlen(String_Expression) Returns the length of the String_Expression. cstring
strncat(String_Variable, String_Expression, Limit); Same as strcat except that at most Limit characters are appended. cstring
strncmp(String_Exp1, String_Exp2, Limit) Same as strcmp except that at most Limit characters are compared. cstring
strncpy(String_Variable, String_Expression, Limit); Same as strcpy except that at most Limit characters are copied. cstring
strstr(String_Expression, Pattern) Returns a pointer to the first occurrence of the string Pattern in String_Expression. Returns the NULL pointer if the Pattern is not found. cstring
strchr(String_Expression, Character) Returns a pointer to the first occurrence of the Character in String_Expression. Returns the NULL pointer if Character is not found. cstring
strrchr(String_Expression, Character) Returns a pointer to the last occurrence of the Character in String_Expression. Returns the NULL pointer if Character is not found. cstring

1 Some implementations place it in cmath.

2 Returns an integer that is less than zero, zero, or greater than zero according to whether String_Exp1 is less than, equal to, or greater than String_Exp2, respectively. The ordering is lexicographic ordering.