For the malloc statement below, I am failing to initialize a variable-sized object
int textsize = BUF_SIZE; char *lines[textsize] = malloc(sizeof(char *) * textsize);
The objective is to have an array of pointers where each will store the pointers to STDIN lines entered by the user. textsize is the number of lines that is supported as input by the user.
Error:
error: variable-sized object may not be initialized char *lines[textsize] = malloc(sizeof(char *) * textsize);
https://stackoverflow.com/questions/66084440/malloc-error-cant-assign-to-variable-sized-object February 07, 2021 at 12:03PM
没有评论:
发表评论