struct DATE
{
int year;
int month;
int day;
};
main()
{
struct DATE date;
date.year=2003;
date.month=9;
date.day=21;
char temp[20];
memset(temp,0,20);
strncpy(temp,(char*)&date,20);
cout<<"temp="<<*temp<<endl;
}
好像有问题?
...全文
19277打赏收藏
怎样实现把一个结构体中的数据存放到数组中,然后输出?
struct DATE { int year; int month; int day; }; main() { struct DATE date; date.year=2003; date.month=9; date.day=21; char temp[20]; memset(temp,0,20); strncpy(temp,(char*)&date,20); cout<<"temp="<<*temp<<endl; } 好像有问题?