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;
}
输出结果:
#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;
}
输出结果:
相关文章推荐
- C语言strlen函数和sizeof操作符
- C语言 sizeof函数详解
- C语言中用函数实现整型数据位宽,如16,32位,不可以使用sizeof
- [c语言]sizeof() 居然不是函数?!!strlen()和sizeof()纠缠在一起再碰到不同类型的数组,你还能分辨清吗?
- C语言 sizeof函数详解
- C语言 sizeof函数详解
- C语言 sizeof函数详解
- C语言 sizeof函数详解
- c语言之sizeof函数
- C语言中sizeof()与strlen()函数的使用入门及对比
- C语言 sizeof函数详解
- c语言:sizeof的使用,其不是函数,是一个操作符关键字,定义一个数组arr,输出arr和&arr的区别
- C语言 sizeof函数详解
- C语言中strlen()函数和sizeof()函数区别[关于字符串长度]
- C语言sizeof()和strlen()函数的区别
- 【C语言】数组名传递给函数,数组的sizeof变为4的原因
- 转载并学习 C语言 sizeof函数详解
- sizeof不是函数,C语言中sizeof的陷阱
- c语言:sizeof的使用,其不是函数,是一个操作符关键字,定义一个数组arr,输出arr和&arr的区别
- C语言 sizeof函数详解