Greetings from Greece!, Nice to meet you~
Well, I have to write a C script, and while i do have the whole algorithm in mind, I must save certain data as an array of struct at the beginning of the script. I have never used Structs, so i looked them up on the web, and got a handle about them, but I can't seem to fill an array right...
this is my code.
I intend to Loop it in a for, and have the array filled as = { }; but... i dont know if that would work
The errors i get are:
request for member 'id' in something not a struct or union
request for member 'num' in something not a struct or union.
Its 10:15pm here, and I have to attend class at 9am~
Any help would be appreciated, thanks beforehand!
Well, I have to write a C script, and while i do have the whole algorithm in mind, I must save certain data as an array of struct at the beginning of the script. I have never used Structs, so i looked them up on the web, and got a handle about them, but I can't seem to fill an array right...
this is my code.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <signal.h>
typedef unsigned int id_t;
typedef unsigned int num_t;
typedef struct mystr
{
id_t id;
num_t num;
}
mystr;
int main()
{
int i;
mystr st[10]={
[1]={
.id = 0,
.num = 0
},
[2]={
.id = 0,
.num = 0
}
};
}
I intend to Loop it in a for, and have the array filled as = { }; but... i dont know if that would work
The errors i get are:
request for member 'id' in something not a struct or union
request for member 'num' in something not a struct or union.
Its 10:15pm here, and I have to attend class at 9am~
Any help would be appreciated, thanks beforehand!