0

Hello I have this array and I seem to forget how to naviagte through it.

Line* line = (Line*) malloc(sizeof(Line)*line_count);
for (int i = 0; i <line_count; i++){
(line + i) ->blocks = make_blocks(block_count);
(line + i) ->block_count = block_count;

}

Logic:

Line is a pointer to the start of this continuous block of memory. I want to adjust the line pointer by 1 (the size of the line) and make blocks for that specific line and set the block count.

The above (line + i) does not work I have tried line[i] (line + i)* &line[i] but still nothing

Can anyone show me the light ? Its really dark where im sitting.

Thanks

RonJermiah
  • 103
  • 1
  • 2
  • 9

1 Answers1

1

The pointer is of the type Line. You can´t point to blocks like that.

For that you would need to have an array of pointers to type blocks (if that´s a type/struct you made).

fdbva
  • 88
  • 1
  • 6