TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: David Nugent
from: Shane Day
date: 1994-08-19 16:36:00
subject: scanf() gets() me confused

* David Nugent >>> Shane Day  

 >> It is a bit of a bugger.  I've had the same problem when
 >> using cin.  After using a cin.get(char*,int,int) I've found
 >> it is necessary to do a cin.get() after _every_ cin call.

 DN> Then use istream::getline(), where the '\n' is automatically
 DN> discarded, or better yet, define a string class which allows you
 DN> to accept and parse the precise object you're looking for.
 DN> There's little point in using an OOP language unless you're going
 DN> to follow the same philosophy.

I do, normally.  The situation above happened when a teacher wanted me to
write a quick program to do a brain-dead task.

Doesn't istream::getline() include the '\n' in the target string?

Shane

--- FMail 0.94

* Origin: A Saucerful Of Secrets (3:620/260.1)
SEEN-BY: 50/99 54/54 620/243 246 250 251 252 260 262 623/630 624/50 711/409
SEEN-BY: 711/410 430 807 808 809 932 934 712/623 713/888 714/906 800/1
@PATH: 620/260 250 243 54/54 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

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™.