so i posted some code a few days ago and agree it was hard to read.In response to that i was using vector stacks to group a lot of elements together one being directories to text files.
I am trying to learn data base like SQL but at the time needed to make this program.
note:I also would like to know how what you use to save data in a program and it stays when the program exits.
anyway the problem is I tried to save my directories in a vector like this:
Code:
vector<string> files;
files.push_back("C:/bills/default.txt");
files.push_back("C:/bills/jan.txt");
files.push_back("C:/bills/feb.txt");
files.push_back("C:/bills/mar.txt");
files.push_back("C:/bills/april.txt");
files.push_back("C:/bills/may.txt");
files.push_back("C:/bills/june.txt");
files.push_back("C:/bills/july.txt");
files.push_back("C:/bills/aug.txt");
files.push_back("C:/bills/sept.txt");
files.push_back("C:/bills/oct.txt");
files.push_back("C:/bills/nov.txt");
files.push_back("C:/bills/dec.txt");
the reason was so I could make a loop to add and delete elements to all files in one shot
the loop just view the default file looks like this:
Code:
void list(vector<string>files)
{
system("CLS");
string bills;
string file;
int counter=0;
ifstream list;
list.open(files[0]);
if(list.good())
{while(!list.eof())
{getline(list,bills);
cout<<counter<<"."<<bills<<endl;
counter++;
}
}
system("PAUSE");
main();
}
I tried to assign the value to a string file:
still no dice
any idea what i am doing wrong?thanks