c - How can I set the size of char [] with int -
i want create char foo[]
, set size wit int
dosn't work @ all!
}else{ int start = match[1].rm_so; int end = match[1].rm_eo; char value[end-start]; ... }
the size of value
0, why so?
thanks
you should use malloc that.
char *value = malloc( (end-start) * sizeof(char))
when using malloc, remember free memory when done using array.
free(value)
see more here if need more information please : c dynamic memory allocation
Comments
Post a Comment