现在学习C++,书中看到了以下例程:
#pragma hdrstop
#include <iostream>
#include <cstring>
using namespace std;
char *getname(void);
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
char *name;
name = getname();
cout << name << " at " << (int *)name << endl;
delete [] name;
name = getname();
cout << name << " at " << (int *)name << endl;
delete [] name;
return 0;
}
//----------------------------------------------------------------------------
char *getname()
{
char temp[80];
cout << "Enter last name: ";
cin >> temp;
char *pn = new char (strlen(temp) + 1);
strcpy(pn,temp);
return pn;
}
程序的大致意思知道了,但是不明白里面的(int *)name是什么意思?应该是代表输出name的地址吧?
鸿蒙传说
慕容708150
相关分类