基础知识不好,面试又被血虐了啊。。。
#include <iostream>
using namespace std;
bool convertString(char *str,char *deStr, int desBufSize)
{
cout << sizeof(str) << endl; //"4"
// cout << sizeof(char) << endl; //"1"
int srcSize = 0;
while(str[srcSize] != '\0')
srcSize++;
// cout << srcSize << endl;
if(srcSize >= desBufSize)
return false;
else
{
for(int i = srcSize - 1;i>=0;i--)
{
deStr[srcSize-i-1] = str[i];
}
deStr[srcSize] = '\0';
}
return true;
}
int main()
{
char a[8] = "liuchao";
char b[10];
// cout << sizeof(a) << endl;
convertString(a,b,10);
cout << a << endl;
cout << b << endl;
cout << "数据类型大小:"<< endl;
int * c;
cout << sizeof(c) << endl;
cout << sizeof(bool) << " " << sizeof(char) <<" " <<sizeof(int) <<" " << sizeof(float) <<" " << sizeof(double) << endl;
return 0;
}