I'm having a little trouble with some code. I'm writing a library management program. I need to be able to input title, author, isbn, etc. in the program. When the program asks for the isbn it behaves as expected. When I enter any words the program terminates, but if I only enter a single letter it does what I want it to do. To make this post shorter, how do I tell the program to allow a word instead of just a single character? Thanks for the help.
cobaltbass
0
Newbie Poster
Recommended Answers
Jump to PostI'm having a little trouble with some code. I'm writing a library management program. I need to be able to input title, author, isbn, etc. in the program. When the program asks for the isbn it behaves as expected. When I enter any words the program terminates, but if I …
Jump to PostYou can also use Character Arrays
char title[30]; cin.getline(title,30);
This will even take in spaces between words too.
Jump to PostYou can also use Character Arrays
char title[30]; cin.getline(title,30);
This will even take in spaces between words too.
Too 'C' for me. How about combining the two posts and do it like:
string title; getline(cin, title);
Now we can still use std::strings AND it takes in …
All 12 Replies
VernonDozier
2,218
Posting Expert
Featured Poster
Sky Diploma
571
Practically a Posting Shark
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
cobaltbass
0
Newbie Poster
BAEdwards
0
Newbie Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
FTProtocol
-24
Junior Poster in Training
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
BAEdwards
0
Newbie Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
cobaltbass
0
Newbie Poster
Nick Evan
4,005
Industrious Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.