i'm trying: #define redim(varname,x) sizeof( __typeof__ (varname)) realloc (varname, x * sizeof( __typeof__ (varname)))
i can't use the typeof, unless i must add a library.
error:
"error: expected ';' before 'realloc'"
You use realloc() for dynamically allocated arrays, that you used malloc() or calloc() to allocate.
1 2 3 4 5 6
int *pi;
pi = malloc(100 * sizeof(int)); // pi can access pi[0] to p[99]
realloc(pi, 250 * sizeof(int)); // pi can access pi[0] to p[249]
free(pi); // dynamically allocated memory must be freed when no longer needed
i'm using C++ 11.
why the macro?
because is then more easy to translate my language to C++
but the fcantoro (1) have right. more simple is impossible.
thanks to all for all