1. C character strings and string functions
In C, character strings are just arrays of characters, with a terminating zero byte marking the end of the string.This implies that you can not put a zero byte in the middle of a string;
you can, but the standard library functions will treat the first zero byte as the end of the string.
Example: char s[80] = { 'a', 'b', 'c', '\0', 'd', 'e', 'f', '\0' } or char s[80] = "abc\0def";strlen(s) will return 3.
There is not much you can do with strings in C without using the standard library string functions.
For example, to change the value of the string s above you can not do:
s = "xyz"; /* illegal */because C does not copy arrays (except, of course, in an initialization part of a declaration).
But you could do either:
s[0] = 'x'; s[1] = 'y'; s[2] = 'z'; s[3] = '\0'; or strcpy( s, "xyz");Note that the illegal statement above would be legal if the left-hand side was a pointer:
char *p; p = "xyz"; /* OK */because, in this case, the array of characters "xyz" is not copied,
only the address of that array is assigned to p.