You are not logged in.
Pages: 1
I was playing a bit with the C99 feature allowing variable sized arrays. This is what I came up with for an example, but does it make sense to do this sort of thing? Its probably safer since you can figure out what size of buffer you need at run time.
My question here is related to initializing the array, it seems a bit convoluted to me. Is there a better way to do the initialization? This is the best I could come up with since you can't directly initialize the array, that's not allowed.
const char ext[] = ".log";
int buffersize = strlen(argv[0]) + strlen(ext) + 1;
char filepath[buffersize];
strcpy(filepath, argv[0]);
strcat(filepath, ext);
Offline
Pages: 1