64,683
社区成员
发帖
与我相关
我的任务
分享
typedef struct iRandom
{
int iVal[4];
}
iRandom;
#include <iostream>
using namespace std;
typedef struct iRandom
{
int iVal[4];
}
iRandom;
int main(){
/*int a[4] = {0, 1, 2, 3};*/
struct iRandom r;
//for(int i = 0; i < 4; i++)
//r.iVal[i] = a[i];
memset(&r, 0, sizeof(iRandom));
for(int i = 0; i < 4; i++)
cout << r.iVal[i] << endl;
system("pause");
return 0;
}
#include <iostream>
using namespace std;
typedef struct iRandom
{
int iVal[4];
}
iRandom;
int main(){
int a[4] = {0, 1, 2, 3};
struct iRandom r;
for(int i = 0; i < 4; i++)
r.iVal[i] = a[i];
for(int i = 0; i < 4; i++)
cout << r.iVal[i] << endl;
system("pause");
return 0;
}
只有在结构体初始化,不是在vector初始
typedef struct iRandom
{
int iVal[4];
iRandom(){memset(iVal, 0, sizeof(int) * 4);}
}
话说vector里面都没元素 ,怎么初始..