first, sizeof gets the number of bytes of an object or type
1. General type
char, int, long, double, etc.
Number of bytes returned and system-related
2. Pointer type
The pointer type is actually the address, 32 is the number of bytes in the system is 4
3, array
Array bytes equal to array type byte number * length of array
4, struct
A multiple of the total number of bytes occupied by the largest member, and the total number of bytes for all members before the maximum member, and must be a multiple of the maximum number of bytes in the largest member.
second, strlen gets the length of the string, with "" "as the end flag, and does not count it.
int a =0;
char c =0;
int *PA = &a;
char* pc =&c;
int sa[10];
Char sc[10]={1,1,1,1,1};
CHAR*PSC=SC;
struct sts1{
char tc;
int ta;
};
struct sts2{
char tc;
Char tc2;
int ta;
};
printf ("A%d\n", sizeof (a)); 4
printf ("C%d\n", sizeof (c)); 1
printf ("Pa%d\n", sizeof (PA)); 4
printf ("PC%d\n", sizeof (PC)); 4
printf ("sa%d\n", sizeof (SA));
printf ("sc%d\n", sizeof (SC));
printf ("PSC%d\n", sizeof (PSC)); 4
printf ("Strlen psc%d\n", strlen (PSC)); 5
printf ("Sts1%d\n", sizeof (struct sts1)); 8
printf ("Sts2%d\n", sizeof (struct sts2)); 8
~end~