您的位置:首页 > 编程语言 > C语言/C++

C语言sizeof()函数

2013-10-27 00:26 288 查看
测试代码:

#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;

}

输出结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: