C Language - String Arrays, Pointers, and Safe Copying
1. C Language Strings In the C language, a string can be defined as a continuous memory area of characters (char) terminated by a Null character ('\0') . The Null character is represented as '\0' or 0x00 . There is no dedicated data type for representing strings; string handling is performed through pointers and arrays. #include <stdio.h> #include <string.h> int main () { char str[ 16 ]; strcpy (str, "012345678901234" ); printf ( "%s,len=%zu,size=%zu\n" , str, strlen (str), sizeof (str)); return 0 ; } ※ Local variables declared without initialization, such as char str[32] , have their memory space filled with undefined values (garbag...