Alright guys, I am working on a flashcard script... Previously I had it so that it onlty had predefined categories. People were complaining, so now I am trying to make it to where it reads flashcards.txt and then gets the categories from there.
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:
important parts of main.cpp:
[code=cpp]
int menu(vector<str ing> 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("flashca rd.txt");
vector<string> menu1;
vector<string> file;
if(themen.is_op en()==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.e of())
{
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);
}
}
[/code]
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:
Code:
topic random|topic.txt topic bob|bob.txt
[code=cpp]
int menu(vector<str ing> 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("flashca rd.txt");
vector<string> menu1;
vector<string> file;
if(themen.is_op en()==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.e of())
{
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);
}
}
[/code]
Comment