1 # include
2 # include
3 # include
4 int main (INT argc, char ** argv)
5 {
6 char * Ss = "0123456789 ";
7 printf ("string sizeof (SS) is % d/N", sizeof (SS); // for the type, SS is Pointer
8 printf ("string sizeof (* ss) is % d/N", sizeof (* ss )); // * ss is the first character of the string
9 printf ("string sizeof (Wanglei) is % d/N", sizeof ("Wanglei ")); // at this time, Wanglei should be stored in the array by default.
the number of bytes that "Wanglei" occupies
10 printf ("string strlen (SS) is % d/N", strlen (SS); // strlen is not counted as '/0'
11
12 char SSS [20] = {"1234567890 "};
13 printf ("array sizeof (SSS) is % d/N", sizeof (SSS ));
14 printf ("array strlen (SSS) is % d/N", strlen (SSS ));
15}
In short, sizeof is the number of bytes occupied by computation.
String sizeof (SS) is 4
String sizeof (* ss) is 1
String sizeof (Wanglei) is 8
String strlen (SS) is 10
Array sizeof (SSS) is 20
Array strlen (SSS) is 10