Here are a number of useful functions work with character arrays (C-strings).
The types of the parameters are cs=char[]
or char*
,
c=char/int
.
Where true
appears, zero is false and non-zero is true.
Type | Method | Description |
---|---|---|
#include <cstring> (or older <string.h> ) | ||
int | strlen(const cs) | Returns the length of the c-string cs. |
char* | strcpy(cs1, const cs2) | Copies cs2 to cs1. Returns the first parameter (usually ignored). |
char* | strcat(cs1, const cs2) | Concatenates cs2 on the end of cs1. Returns the first parameter (usually ignored). |
int | Returns one of three kinds of values: negative if cs1 < cs2, zero if cs1 == cs2, or positive if cs1 > cs2. | |
strchr(const cs, c) | Returns a pointer to the first occurrence of c in cs or NULL if it isn't in the string. | |
strstr(const cs1, const cs2) | Returns a pointer to the first occurrence of cs2 in cs1 or NULL if it isn't in the string. |