0

Hi
i had never before used structures, so i am a complete noob ;) . this is a small Part of my programm:

struct player
{
    int var1;
    int var2;
    int var3;
    int var4[10];
    int var5;
    int var6;       
};                     
struct player p[4]=   {{1000,0,0,{0,0,0,0,0,0,0,0,0,0},0,1},
                       {1000,0,0,{0,0,0,0,0,0,0,0,0,0},0,1},
                       {1000,0,0,{0,0,0,0,0,0,0,0,0,0},0,1},
                       {1000,0,0,{0,0,0,0,0,0,0,0,0,0},0,1}};

printf("%d\n"), p[0].var1;
printf("%d\n"), p[0].var2;
printf("%d\n"), p[0].var3;
printf("%d\n"), p[0].var4[0];
printf("%d\n"), p[0].var5;
printf("%d\n"), p[0].var6;
getch();

But the initialization doesn't work! i get the follow numbers:

var1:    1090519874
var2:    1090519874
var3:    1090519874
var4[0]: 1090519874
var5:    1090519874
var6:    1090519874

Can someone help me pls?

p.s: sorry for the bad english :(

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by tischn
0

The initialization is fine; the problem is a typo in your printf() calls. The closing paren is misplaced. Try this instead:

printf("%d\n", p[0].var1);
printf("%d\n", p[0].var2);
printf("%d\n", p[0].var3);
printf("%d\n", p[0].var4[0]);
printf("%d\n", p[0].var5);
printf("%d\n", p[0].var6);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.