测试代码:
#include "stdafx.h"
#include "iostream"
using namespace std;
int Testsizeof(char buf[]);
int _tmain(int argc, _TCHAR* argv[])
{
int a;
int buf[10];
char buffer[10];
char *p;
struct node{
int a;
char buf[20];
struct node *next;
}*pnode;
cout<<"sizeof(a) = "<<sizeof(a)<<endl;
cout<<"sizeof(buf) = "<<sizeof(buf)<<endl;
cout<<"sizeof(buffer) = "<<sizeof(buffer)<<endl;
cout<<"sizeof(node) = "<<sizeof(node)<<endl;
cout<<"sizeof(pnode) = "<<sizeof(pnode)<<endl;
cout<<"传参测试"<<endl;
Testsizeof(buffer);
return 0;
}
int Testsizeof(char buf[])
{
//sizeof 输出的是结果
cout<<"函数参数里的sizeof(buf) = "<<sizeof(buf)<<endl;
return 0;
}
输出结果: