Wednesday 25 July 2012

cstring Library

<cstring>

Functions for performing string-like operations on arrays of char marked with a terminating '\0' (such as "quoted literals" or as returned by string::c_str(). Mostly obsoleted by type string.
strcpy(dst, src); // Copy src to dst. Not bounds checked
strcat(dst, src); // Concatenate to dst. Not bounds checked
strcmp(s1, s2); // Compare, <0 if s1<s2, 0 if s1==s2, >0 if s1>s2
strncpy(dst, src, n); // Copy up to n chars, also strncat(), strncmp()
strlen(s); // Length of s not counting \0
strchr(s,c); strrchr(s,c);// Address of first/last char c in s or 0
strstr(s, sub); // Address of first substring in s or 0
// mem... functions are for any pointer types (void*), length n bytes
memcpy(dst, src, n); // Copy n bytes from src to dst
memmove(dst, src, n); // Same, but works correctly if dst overlaps src
memcmp(s1, s2, n); // Compare n bytes as in strcmp
memchr(s, c, n); // Find first byte c in s, return address or 0
memset(s, c, n); // Set n bytes of s to c

No comments:

Post a Comment