Many functions exist to read, write or copy strings from and to different sources and destinations. The following lists some popular functions.
int strlen(char s[]); // returns the lenght of string s char* strcopy(char dest[], char source[]); // copies the source string into the destination. // Note that dest must be at least as big as source or some // adjacent memory will be overwritten. If dest is bigger // we will have a memory leak. int strlen(char * s); // same as above but using pointers (see below)
String handling in C is best explained by showing the implementation of strlen functions:
int strlen(char s[]) { int x = 0; while (s[x] != '\0') // not string end yet x++; // increment index return x; }