Im trying to find a way to open several files with different names.
My first problem creating this program is, how come that 'fopen()' which is a C++ function takes a C const char* argument?
I thought we were supposed to use strings with C++.
This is what i have so far, trying to figure out how to use strings.
Code:#include <iostream>
#include <string>
using namespace std;
int main ()
{
FILE * pFile;
int i = 0;
char ch[5] = {0,1,2,3,4};
string str = "file.txt", str2;
pFile = fopen (str,"w");
while (i<5)
{
cout << "Enter word: "; cin >> str2;
str.append(ch[i]);
fprintf(pFile, str2);
fclose (pFile);
i++;
}
return 0;
}