傻了:new出来的数组,如何计算它的大小?sizeof么,进来看看。。。
AnsiString Str1 = "abcde12345";
char *tt = new char[Str1.Length() + 1];
strcpy(tt, Str1.c_str());
Edit1->Text = IntToStr(sizeof(tt)); //不论Str1内容为何,此处始终为4
delete [] tt;
本来是想求出new出来的char数组占用多少字节,难道这样用sizeof只能算出数组指针本身的大小?那么如何求整个数组的大小呢?而下面的代码却是对的:
char Str2[] = "abcde12345";
Edit2->Text = IntToStr(sizeof(Str2)); //此处就返回11