In a C/C++ program, is it correct for me to do this:
int i;
FILE **files = malloc(numFiles * sizeof(FILE *));
std::string file("foo"), ext(".bar");
char *num[10];
for (i = 0; i < numFiles; i++) {
files[i] = fopen((file + itoa(i, num, 10) + ext).c_str(), "w");
}
This is basically what I am doing, but I am not getting anything written to the files. They're blank.
EDIT
I have fixed my problem. I thought I might be doing something wrong here, but it turned out to be elsewhere. Thanks for the responses, anyway.
std::string, why not other C++ features instead of, say, raw arrays.