Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Hello I'm trying to figure out how to use a structure variable array like so :

This is the declaration of that struct :

 typedef struct tagCORD {
  LONG x;
  LONG y;
} CORD, *CCORD; 

This is the structure array being initialized :

int value;

CORD Cord[value]; 

This is how I want to use my structure array in my user defined function declaration:

void CordValues(cord[value], int p0x, int p0y, int p1x, int p1y, int p2x, int p2y)
  {
    Cord[0].x = p0x;
    Cord[0].y =  p0y;

    Cord[1].x = p1x;
    Cord[1].y = p1y;

    Cord[2].x = p2x;
    Cord[2].y =  p2y;
  } 

then in main :

CordValues(cord[2], 100, 125, 200, 95, 270, 155, 270);

so if you still don't understand let me explain it more in-depth

I want to create and be able to use the value of cord and use it within the above user defined function declaration as well as the scope of that user defined function declaration.

Thanks in Advance.

share|improve this question
I'm not 100% sure what you are trying to do here. Are you trying to pass an individual instance of the struct (from the array) as a parameter, or do you want to pass the whole array of structs as a parameter? – Jason H Apr 19 '12 at 12:01
none of those actually now that I rethink. I want to be able to use "value" throughout the overall code as non changing number that can be used as a value for a function at the same time as a single const int or any other container type. – NoobScratcher Apr 19 '12 at 12:04
for a structure not a function sorry *** – NoobScratcher Apr 19 '12 at 12:11
Can you use a define? Like #define value 3? – Petr Abdulin Apr 19 '12 at 14:28
"This is the declaration of that struct :" Is this C++ or C? In general, you don't see much typedef struct among C++. – Nicol Bolas Apr 19 '12 at 16:46
show 1 more comment

closed as off topic by Tetrad Apr 19 '12 at 17:00

Questions on Game Development Stack Exchange are expected to relate to game development within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.