www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/30/05:21:51

Message-ID: <3700A43A.776D793F@home.com>
From: Shaun Jackman <sjackman AT home DOT com>
X-Mailer: Mozilla 4.5 [en] (Win95; I)
X-Accept-Language: en,fr
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Using cin and getline
Lines: 27
Date: Tue, 30 Mar 1999 10:16:39 GMT
NNTP-Posting-Host: 24.113.47.11
X-Complaints-To: abuse AT home DOT net
X-Trace: news.rdc1.bc.wave.home.com 922788999 24.113.47.11 (Tue, 30 Mar 1999 02:16:39 PDT)
NNTP-Posting-Date: Tue, 30 Mar 1999 02:16:39 PDT
Organization: @Home Network Canada
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'm having a problem with the following code snippet, where the input
from cin is (for example):
[BEGIN input]
abcdefgh
ijklmnop
[END input]

string name;
char buf[80];
cin >> name;
cin.getline(buf,80);

Name is written to properly, but it doesn't even wait for input when it
comes to the getline. The following code snippet works.

string name;
char buf[80];
cin >> name;
cin.get(); // This never happens
cin.getline(buf,80);

The above is a real hack. What is my problem, and how do I fix it?

Thanks for your help,
Please reply by e-mail as well if possible,
Shaun Jackman
sjackman AT home DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019