Yes I know that, how do you get a user to enter a new book? Here is my latest code:
cout << "Enter book to add: "<< endl;
getline(cin, book);
books.push_back (book);
the error says that there is no function call to getline. ??? I have all the appropriate header files.
User Profile
Collapse
-
How to add strings to vectors?
Hi,
I have a vector I want to add book titles to, then i want to print my updated vector. This is best I have come up with but the program fails at the getline line. why? and how can I fix this?
string book;
cout << "Enter book to add: "<< endl;
getline(cin, book);
books.push_back (book);
for(int i = 0; i < books.size(); ++i)... -
Yes that would print the book name, but it wouldn't add it to the vector. I want to add the book to my vector.Leave a comment:
-
Sorry, I copied my code wrong. Suppose I have (yesorno == 'y').
How do I get it to run? When I debug, I get the same response as when I run the program.
I get alot of this message:/usr/include/c++/4.2.1/ostream:225: note: std::basic_ostr eam<_CharT, _Traits>& std::basic_ostr eam<_CharT, _Traits>::opera tor<<(long double) [with _CharT = char, _Traits = std::char_trait s<char>]
/usr/include/c++/4.2.1/ostream:229:...Leave a comment:
-
Adding strings to vectors
Hi,
I am a newbie at programming. I was given a project to program a library catalog. One of the aspects is that we have to allow an administrator to add, modify, and delete books from the catalog. It was recommended to me to use vectors. So I initialized by hand a default book list, and now I want to be able to have an adminisistrator add books and then print the modified book list. Here is what I have got:
main () {
char...
No activity results to display
Show More
Leave a comment: