output/input mutiple files to desktop
working on some code that will place (output/input) 5 different files onto
my desktop. Finally, got it down to one error message which is "error
<23>: C2109: subscript an array or pointer type is required". Its with
myfile.open; I've tried -> operator. Not exactly how to make this into an
array, if that is what I'm suppose to do as I have tried making string
into char and warnings occur. Can anybody let me know how I can modify my
code to correct this? I'm relatively new to C++ and programming, only a
few months.
#include <iostream>
#include <fstream>
using namespace std;
struct pizza{
string FILENAMES[9];
};
int main ()
{
int i;
char FILENAMES;
pizza greg = {"file1.doc", "file2.doc", "file3.doc", "file4.doc",
"file5.doc"};
cout << "Input is invalid. Program will end. " << "\n" ;
for (i = 0; i < 5; i++)
{
const char *path="/Desktop/Libraries/Documents" ;
ofstream myfile(path);
myfile.open (FILENAMES[i]) ;
myfile << "How you like math?\n" ;
myfile.close();
};
return 0;
}
No comments:
Post a Comment