Hi,
I have decalared a structure named record as given below and also created a function called read() inside the structure. The function works fine when I call it using this statement:
myRecord.read();
but I want to create one more function which can be called to initilize all the variables and arrays.
When I tried to initialize an array inside the structure, it gave an warning message message that "for loop... can't be expanded inline."
What should I do to initiliza arrays defined inside a structure?
When I write the user input to a text file, garbage values are also written. So, I want to initialize arrays before using them.
Inside the given below structure if I create a function similar to the read() one, it doesn't work and wranings come:
void init() {
int count = 0; //This initialization works fine.
for(count = 0; count < 100; count++) {
a[count] = ' ';
}
}
Can anybody help me?
void main() {
clear;
typedef struct record {
char q[100];
char a1[100];
char a2[100];
char a3[100];
char a4[100];
void read() {
printf("\nQuestion: ");
gets(q);
printf("\nA: ");
gets(a1);
printf("\nB: ");
gets(a2);
printf("\nC: ");
gets(a3);
printf("\nD: ");
gets(a4);
//printf("\nChoice: ");
//scanf("%d",can);
};
}record;
record myRecord;
myRecord.read();
}