#include "iostream"
using namespace std;
int main()
{
char* Code;
Code = (char *)malloc(100);
memset(Code, 0, 100);
cout << "!" <<sizeof(Code)<< "!"<< endl<<Code<<endl;
cout << "int:" << sizeof(int) <<endl;
cout << "char:" << sizeof(char) <<endl;
cout << "double:" << sizeof(double) <<endl;
cout << "float:" << sizeof(float) <<endl;
cout << "!" <<sizeof(Code)<< "!"<< endl<<Code<<endl;
system("pause");
return 0;
}
using namespace std;
int main()
{
char* Code;
Code = (char *)malloc(100);
memset(Code, 0, 100);
cout << "!" <<sizeof(Code)<< "!"<< endl<<Code<<endl;
cout << "int:" << sizeof(int) <<endl;
cout << "char:" << sizeof(char) <<endl;
cout << "double:" << sizeof(double) <<endl;
cout << "float:" << sizeof(float) <<endl;
cout << "!" <<sizeof(Code)<< "!"<< endl<<Code<<endl;
system("pause");
return 0;
}
在vc6.0中输出值为4,在vs2013输出值为8。
找到原因了:
虽然初始化了,但是没有用具体的值,所以sizeof得到的应该是存储指针的那个大小,是固定的。如vc6.0是4,vs2013是8.