delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/06/22/06:17:12

From: "Nigz" <n DOT bachmannNO AT SPAMcardiff DOT govOK DOT uk!>
Newsgroups: comp.os.msdos.djgpp
Subject: getline problem
Lines: 41
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: <QAl45.6554$_55.140617@news2-win.server.ntlworld.com>
Date: Thu, 22 Jun 2000 11:09:27 +0100
NNTP-Posting-Host: 194.168.45.250
X-Complaints-To: abuse AT net DOT ntl DOT com
X-Trace: news2-win.server.ntlworld.com 961668528 194.168.45.250 (Thu, 22 Jun 2000 11:08:48 BST)
NNTP-Posting-Date: Thu, 22 Jun 2000 11:08:48 BST
Organization: ntl Business News Service
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I am using rhide & have the following segment of code:

cin.getline(forename,20);
/* then to empty buffer */
  if(strlen(forename)==19)
  {
    cin.get(ch);
    while(ch != '\n')
      cin.get(ch);
  }

This I believe is correct - it compiles ok, but if I enter a forename of
greater length than 20 chars - it hangs or appears to go into an infinite
loop, however if I try to print the characters nothing shows on the screen,
it's as if it is printing infinite spaces i.e. it clears the screen.  If I
do the following

count=0;
cin.getline(forename,20);
/* then to empty buffer */
  if(strlen(forename)==19)
  {
    cin.get(ch);
    while(ch != '\n')
      cin.get(ch);
    count++;
    if(count == 50)break;
  }

There is obviously something still in the buffer even though I entered a
forename of 'say' 30 chars,

Am I being really stupid or is this a bug, many thanks....

--


Regards
Nigz


- Raw text -


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