#include<iostream>
#include<string>
using namespace std;
int main(void) {
struct STRCT {
int num;
string str1,
arrStr1[],
str2,
arrStr2[];
};
int a;
string b[2],
c[3],
d,
e;
a = 10;
b[0] = "hello";
b[1] = "world";
c[0] = "stack";
c[1] = "over";
c[2] = "flow";
d = "random";
e = "text";
//how do i intialize the arrays (arrStr1[] and arrStr2[]) in aStruct along with the rest of items?
//is it like this?
//i want aStruct[] to be an array and i want its size to be declared from the start to later be filled with vals
STRCT aStruct[2];
//then later in the program i want to assign aStruct[] vals
aStruct[0] = {a, //int
d, //string
{b}, //string[]
e, //string
{c}}; //string[]
}
所以基本上我想要一个结构数组与内部数组然后获得适当的vals,然后将适当的值分配给结构数组内的数组。感谢你在非常多的帮助在结构中初始化字符串数组
感谢您的回复,我将在下周学习时尽快使用载体。所以没有办法通过类似于我所招募的方法直接填充arrStr1 []等。 – Tech 2012-07-13 06:02:19
你试过你的方法吗?它工作吗? – Jeeva 2012-07-13 06:03:18
不,编译器会抛出一个“expect; before {”error – Tech 2012-07-13 06:16:51