Hey guys!
First of all english is not my main language so sorry for any english mistakes.
Im from Portugal!
- The problem statement, all variables and given/known data:
Im having a problema creating and array of structs for a work i need to do. (xLib)
- Relevant commands, code, scripts, algorithms:
So i created a struct, that holds 4 ints:
X = X position
Y = Y postion
dimX = horizontal dimension
dimY = vertical dimension
this 4 ints represent a rectangle.
The struct:
typedef struct _blocks {
int X, Y ,dimX, dimY;
} str_blocks;
So now i want to assign values to this int's, but since i dont want just one rectangle i want, for example 3, the best thing to do is to create an array of this struct right?
So for 3 rectangle:
str_blocks blocks[3];
blocks[0] = {50, 50, 150, 20};
blocks[1] = {200, 50, 150, 20};
blocks[2] = {300, 150, 150, 20};
So this doesnt work and i dont know why. ive been looking in the internet and
saw lots of examples where they declare the values like this, im obviously missing something...
Tried to assign value by value:
blocks[0].X = 50;
blocks[0].Y = 50;
blocks[0].dimX = 150;
blocks[0].dimy = 20;
blocks[1].X = 200;
blocks[1].Y = 50;
blocks[1].dimX = 150;
blocks[1].dimy = 20;
blocks[2].X = 300;
blocks[2].Y = 150;
blocks[2].dimX = 150;
blocks[2].dimy = 20;
- The attempts at a solution (include all code and scripts):
I tried to use:
str_blocks blocks[3];
blocks[0] = {50, 50, 150, 20};
blocks[1] = {200, 50, 150, 20};
blocks[2] = {300, 150, 150, 20};
To give diferent values to the blocks.
- Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Im from Portugal anyway.
ESTG IPVC Portugal - Viana do Castelo
Engenharia da Computa��o Gr�fica e multim�dia.
Teacher name: Jo�o Raposo
www . estg . ipvc . pt