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 :(

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);

Thank you it works xD

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.