TIP: Click on subject to list as thread! ANSI
echo: cis.languages
to: ALL
from: David Breeding 72330,2051
date: 1995-03-25 12:53:23
subject: #scanf() question

#: 20862 S3/Languages
    25-Mar-95  12:53:23
Sb: #scanf() question
Fm: David Breeding 72330,2051
To: ALL

How do you all handle this?

  scanf( "%d",num);
  gets( "%s", string);

Seems what happens, scanf gets the number, but leaves the carriage return
buffered, and on a subsequent gets(), or any other string call.. it
retrieves the newline.  The only remedy I could come up with is to follow
each scanf() with a getchar().  It works, but doesn't seem very elegant.

Any "elegant" solutions?

                         -- David Breeding --
       CompuServe : 72330,2051              Delphi :  DBREEDING
           ***  Sent via   InfoXpress/OSK - Vr. 1.02   ***

There is 1 Reply.

SOURCE: compuserve via textfiles.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™.