sizeof用法注意

// EX_EXAM.cpp : 定義控制檯應用程序的入口點。
//

#include "stdafx.h"
#include <iostream>
using namespace std;

void Foo (char str[100])
{ 
	cout<< sizeof( str ) <<endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
	char *a="he";
	char b[]="he";
	Foo(a);
	cout<<sizeof(a)<<endl;
	cout<<sizeof(b)<<endl;
	cout<<strlen(a)<<endl;
	return 0;
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章