Navigation(slides)

7.8.1 String Operations

We have already mentioned the string functions strlen, strcpy, strcat, and strcmp, found in <string.h>. In the following, s and t are char *'s, and c and n are ints.

strcat(s,t)     concatenate t to end of s
strncat(s,t,n)  concatenate n characters of t to end of s
strcmp(s,t)     return negative, zero, or positive for s < t, s == t, s > t
strncmp(s,t,n)  same as strcmp but only in first n characters
strcpy(s,t)     copy t to s
strncpy(s,t,n)  copy at most n characters of t to s
strlen(s)       return length of s
strchr(s,c)     return pointer to first c in s, or NULL if not present
strrchr(s,c)    return pointer to last c in s, or NULL if not present
ch3n2k.com | Copyright (c) 2004-2020 czk.