Originally Posted by
workisnotfun
Would allocating memory to the pointers, then assigning those values to it be a good solutions?
Something like the following?
Code:
static const char original[] = "Something";
char *string;
size_t length;
/* We need length + 1 characters. */
length = strlen(original);
string = malloc(length + 1);
if (!string) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
/* Initialize the string. We know string is long enough. */
strcpy(string, original);
Or, if you have POSIX.1-2008 support,
Code:
#define _POSIX_C_SOURCE 200809L
char *string;
string = strdup("Something");
if (!string) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
both will give you a dynamically allocated pointer, to a string "Something", you can reallocate.