I keep getting an "Expected Primary Expression before '>' token " in this line:
cin.ignore(numeric_limits<streamsize>::max(),'\n');
and i'm not sure how to fix it
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
void createBook()
{
string Title;
string Author;
string Genre;
int numberOfPages;
ofstream myfile;
int choice = 0;
cout<<"Welcome back"<<endl<<endl;
cout<<"What would you like to do?"<<endl<<endl;
cout<<"Make Book(1)"<<endl;
while((!(cin >> choice)) || (choice>2 ||choice <1 )){
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "\nInvalid input. Try again: ";
}
cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
if (choice == 1){
cout<<"Enter Title"<<endl;
getline(cin, Title);
cout<<"Enter Author"<<endl;
getline(cin, Author);
cout<<"Enter #ofPages"<<endl;
cin>>numberOfPages;
cin.ignore;
cout<<"Enter Genre"<<endl;
getline(cin, Author);
myfile.open ("Books.txt", ios::out | ios::app);
myfile << Title <<"\n";
myfile << Author <<"\n";
myfile << Genre <<"\n";
myfile << numberOfPages <<"\n";
myfile << "$" <<endl;
myfile.close();
}
else if(choice == 2)
{
return ;
}
}
|
Last edited on
Thanks, i think it fixed it but now its saying at the of my entire code :
'ERROR SUCCESS' was not declared in this scope
Last edited on
Oh yup just forgot a #include, its working now, thanks