C Passing a struct, that contains a struct array -


im trying array of structs contained inside struct eg (struct1.structarray[])

the code looks following:

struct bullet{     int x;     int y;     int exist;     int type; };  struct tank{     int x;     int alive;     int shotsfired;     struct bullet shots[50]; }; 

im trying pass shots[] struct pointer following function.

int get_alien_collision(struct bullet *bulletstruct) 

the line of code im using pass struct follows.

a = get_alien_collision(&player.shots[i]) 

i unable access of data in shots[i] inside function (i confirmed attempting print value of "bulletstruct->x" screen first 20 , 0 when prints fine struct in main())

my full code (on pastebin) main.c , calculations.c incredibly messy , filled lots of bad practices, since first time coding in (what believe c)

if want more explicit can use parens, or can make sure passing right thing defining intermediates like:

struct bullet currentbullet=player.shots[i]; struct bullet *bp=&currentbullet; get_alien_collision(bp); 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -