Xlib help - Array of Structs

Hey guys!
First of all english is not my main language so sorry for any english mistakes.
Im from Portugal!

  1. 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)

  1. 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;
  1. 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.

  1. 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

Thank you for completely answering the homework template.

Please use code tags, like

```text
 stuff 
```

to post code. This preserves indentation in your code, makes it clear where code begins and ends, and prevents random things from turning into smilies.

I see a typo in some of your code. dimy vs dimY. Except for that, your 'assign by value' code actually worked -- so I suspect there's something else wrong in code you didn't post. Please post your complete program.

Also, the only time you can assign whole blocks of memory with { ... } is when the variable is being declared -- so you could do this:

typedef struct _blocks {
    int X, Y ,dimX, dimY;
} str_blocks;

int main()
{
        str_blocks blocks[3]={
                {50, 50, 150, 20},
                {200, 50, 150, 20},
                {300, 150, 150, 20},
        };

}