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 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 …
Jump to PostI don't use Borland Turbo C++ (and neither should you), but try this:
#include <string> #include <iostream> int main() { std::string s = "works!"; std::cout << s << "\n"; return 0; }
I strongly suggest that you upgrade to a new compiler. That way you can program …
Jump to Postwhen using char arrays isn't it recommend to use 256 blocks of memory or bytes?
char blah[256]={0};
Never heard of that. Looks to me as a waste of memory.
If you said: 4 bytes then I would somewhat agree (on a 32 bits OS that is).i read …
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.