Basic C programming help needed
Well I just started my computer science I class and I need some help with structs. I pretty much failed structs in my intro to c class but did well on everything else so i made it out with a B.
I've been learning them on my own the past few days and I understand structs like:
Code:
struct people {
int age;
int height;
int weight;
} person[5];
//then defining them like:
person[1].age = 12;
person[1].height = 60;
person[1].weight = 140;
and so on. But for my program I need to use a character member that will at most take in a 19 character name and an integer member with 6 different numbers (for a lotto ticket)
Here's how i have it as:
/*num_people is the first line in the file we are getting the data from, is that correct usage of it?*/
Code:
struct people {
char name[19];
int numbers[6];
} person[num_people];
person[1].name = "Llewellyn Mark";
person[1].numbers = {1, 2, 3, 4, 5, 6};
/* We need to take the names and numbers from a file but I first want to understand it from direct input which I don't yet because the above doesn't compile*/
So basically what would the above look like done correctly? I haven't been able to figure it out.