0

I am trying to assign a block of memory to an address which already exists.

typedef struct _schedule{
    char stop[MAX_LEN];
    int time;
}schedule;

schedule *p_sch = calloc(2, sizeof(schedule));

after initialize 2 schedule blocks and then I want to create another 3 schedules

But when I do this.

p_sch+3 = (schedule*)calloc(two,sizeof(schedule));

it shows an error "expression is not assignable".

Can I use calloc to specific address in c?

Stefan Scheller
  • 953
  • 1
  • 12
  • 22
  • 3
    You should investigate [`realloc()`](https://en.cppreference.com/w/c/memory/realloc). – Ken Y-N Jul 15 '20 at 04:32
  • If the space following the allocated blocks is not available, the system can not give you another block. Please note that `realloc()` might return `NULL` or a different address. – the busybee Jul 15 '20 at 07:43

0 Answers0