Defines functions for handling character arrays.
|
|
|
Function
|
memcpy
|
Copies contents of a source storage area of a specified length to a destination storage area.
|
strcpy
|
Copies contents of a source string including the null character to a destination storage area.
|
strncpy
|
Copies a source string of a specified length to a destination storage area.
|
strcat
|
Concatenates a string after another string.
|
strncat
|
Concatenates a string of a specified length after another string.
|
memcmp
|
Compares two storage areas specified.
|
strcmp
|
Compares two strings specified.
|
strncmp
|
Compares two strings specified for a specified length.
|
memchr
|
Searches a specified storage area for the first occurrence of a specified character.
|
strchr
|
Searches a specified string for the first occurrence of a specified character.
|
strcspn
|
Checks a specified string from the beginning and counts the number of consecutive characters at the beginning that are not included in another string specified.
|
strpbrk
|
Searches a specified string for the first occurrence of any character that is included in another string specified.
|
strrchr
|
Searches a specified string for the last occurrence of a specified character.
|
strspn
|
Checks a specified string from the beginning and counts the number of consecutive characters at the beginning that are included in another string specified.
|
strstr
|
Searches a specified string for the first occurrence of another string specified.
|
strtok
|
Divides a specified string into some tokens.
|
memset
|
Sets a specified character for a specified number of times at the beginning of a specified storage area.
|
strerror
|
Sets an error message.
|
strlen
|
Calculates the length of a string.
|
memmove
|
Copies contents of a source storage area of a specified length to a destination storage area. Even if a part of the source storage area and a part of the destination storage area overlap, correct copy is performed.
|
Implementation-Defined Specifications
When using functions defined in this standard include file, note the following.
(1) | On copying a string, if the destination area is smaller than the source area, correct operation is not guaranteed. |
char a[]="abc";
char b[3];
.
.
.
strcpy (b, a);
In the above example, the size of array a (including the null character) is 4 bytes. Copying by strcpy overwrites data beyond the boundary of array b.
(2) | On copying a string, if the source area overlaps the destination area, correct operation is not guaranteed. |
int a[ ]="a";
:
:
strcpy(&a[1], a);
:
In the above example, before the null character of the source is read, 'a' is written over the null character. Then the subsequent data after the source string is overwritten in succession.