TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: PHIL OHL
from: TIM HUTZLER
date: 1998-03-20 18:35:00
subject: Re: I`m an idiot

-=>Quoting Phil Ohl to All <=-
PO>I am fairly new at C++ and i have encountered a pretty major problem
PO>(I've had several).  Anyway, I know that you cant use 'cin' if there
PO>is going to be spaces withing your input and I have learned to use
PO>'getline' in its place. However 'getline' doesn't work all the time
PO>either especially when i do something like:
PO>char name[20];
PO>cout<<"Enter name: ";
PO>getline(name, cin);
PO>It just wont work.  How would I remedy this problem without limiting
PO>the user to just their first or last name.
Use the following code:
char name[15];
gets(name,15); //"name" is the string, "15" is the maximum number of chars
PO>I know its a very novice problem but I just don't know.
The I guess you can ask...
We're friendly, damnit! [grin]
___ Blue Wave/QWK v2.12
--- Maximus/2 3.01
---------------
* Origin: Madman BBS * Chico, California * 530-893-8079 * (1:119/88)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.