www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/01/16/05:40:45

From: ams AT ludd DOT luth DOT se (Martin Str|mberg)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: scanf problem
Date: 16 Jan 1999 10:20:52 GMT
Organization: University of Lulea, Sweden
Lines: 19
Message-ID: <77pp64$b8n$1@news.luth.se>
References: <36a00217 DOT 0 AT news DOT sbbs DOT se>
NNTP-Posting-Host: queeg.ludd.luth.se
X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Erik Johansson (perikan AT 2 DOT sbbs DOT se) wrote:
:  I have a problem with scanf.
: char text[50];
: ''scanf("%s",&text)''
: 
: Now, when I enter a string e.g  "John Doe" only the first word "John" is
: inserted into 'text'.

That's how scanf works when given "%s".

: I want both words to be inserted into the same string.

Read the scanf man page ("info libc alph scanf"). There are ways to do
what you want ("%49c"?).


Right,

							MartinS

- Raw text -


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