对于像简单的结构体数据,如:
struct A
{
int a;
int b;
};
A temp[4] = { 0 };
struct A
{
int a;
int b;
string c;
};
A temp[4] = { 0 }; //error
struct A
{
int a;
int b;
string c;
};
/*
*temp:结构体指针
*len:结构体数组长度
*/
int InitAStruct(A *temp,int len)
{
for (int i = 0;i < len;i++) {
temp->a = 0;
temp->b = 0;
temp->c = "";
++temp;
}
return 0;
}
//A temp[4] = { 0 }; //error
A temp[4];
InitAStruct(temp,4);//right