sizeof(char) is 1:
Code:char *foo = malloc(size);
sizeof(char) is 1:
Code:char *foo = malloc(size);
char *f = malloc(1);
Yes, if you wanted to only malloc one char. My example is for allocation of size chars.
My bad it should have been
I forgot the parenthesis at the very end. Anyway this should fix the syntax error;Code:char* storage = malloc(sizeof(char) * size+1);
"Just as eating contrary to the inclination is injurious to the health,
so study without desire spoils the memory, and it retains nothing that it takes in."
- Leonardo De Vinci (1452-1519)