Anyhow, I understand how to do this, and there is nothing wrong with my syntax, because it compiles properly, but whenever it runs, it just starts outputting a bunch of random text, although I did recognize some OS info (at least I think I did.) I am using Win XP SP2.
flashcard.txt:
Expand|Select|Wrap|Line Numbers
- topic random|topic.txt
- topic bob|bob.txt
Expand|Select|Wrap|Line Numbers
- int menu(vector<string> menu1)
- {
- int topic;
- string topics;
- system("CLS");
- cout << "=================================" << endl;
- cout << "= Liberty Flash Cards =" << endl;
- cout << "=-------------------------------=" << endl;
- cout << "= =" << endl;
- system("pause");
- //Somewhere in the following for loop is where the error is
- for(int i=0; i < menu1.size(); i++)
- {
- topics = append(menu1[i], " ", 25);
- cout << "= " << i+1 << ".) " << topics;
- if(i>8)
- {
- cout << "=" << endl;
- }else{
- cout << " =" << endl;
- }
- }
- cout << "= =" << endl;
- cout << "=================================" << endl;
- cout << "What topic would you like to study: ";
- cin >> topic;
- if(!cin)
- {
- fixcin();
- return 0;
- }
- return topic;
- }
- ///////////////////////////////////////////////////////////////
- //main has been edited to only include the important parts. //
- ///////////////////////////////////////////////////////////////
- int main()
- {
- ifstream themen("flashcard.txt");
- vector<string> menu1;
- vector<string> file;
- if(themen.is_open()==0)
- {
- cout << "You must create a \"flashcard.txt\" file \nand place it in the same folder as this program\n";
- system("pause");
- return 1;
- }
- while(!themen.eof())
- {
- getline(themen, temp1, '|');
- getline(themen, temp2);
- // This was done to exclude the | character...
- menu1.push_back(temp1.substr(0,temp1.length()-2));
- file.push_back(temp2);
- }
- topic = menu(menu1);
- while(topic <1 || topic >= menu1.size())
- {
- topic = menu(menu1);
- }
- }