sizeof是C语言的一个运算符(主要sizeof不是函数,虽然用法很像函数),sizeof的作用是用来返回()里面的变量或者数据类型占用的内存字节数。
strlen是一个C库函数,用来返回一个字符串的长度(注,字符串的长度是不计算字符串末尾的‘/0’的),strlen接收的参数必须是一个字符串。
char str[] = "hello"; sizeof(str)=6 sizeof(str[0])=1 strlen(str)=5
char str[] = "hello"; char *p=str; sizeof(p)=4 sizeof(*p)=1 strlen(p)=5
int n=10; sizeof(int)=4 sizeof(n)=4
int b[100]; sizeof(b)=400 // 100*sizeof(int)
void func(int *a) { sizeof(a); } int main(void) { int b[100]; } sizeof(a)=4 // 函数传进去的是地址,不是整个数组
#define dpChar chae * typedef char * tpChar —— 重命名类型
dpChar *p1,p2; // 展开:char *p1,p2; char *p1; char p2;
tpChar *p1,p2; // 等价:char *p1; char *p2;