delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/11/25/08:09:41

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
Subject: Re: gcc problem?
Message-ID: <1038229709.3de220cd6776d@imp.pro.proxad.net>
Date: Mon, 25 Nov 2002 14:08:29 +0100 (MET)
From: CHAUVIERE Jean-Raymond <jr AT chauviere DOT org>
MIME-Version: 1.0
User-Agent: IMP/PHP IMAP webmail program 2.2.42
X-Originating-IP: 195.115.41.103

I didn't program in C for a long time but as far as I remember,
scanf read 1 string using white space as separator.

to enter aaa bbb ccc
you need scanf("%s %s %s", ...) or gets

use gets
or scanf("%s", ..)
followed by
while('\n'!=getchar());
but you loose the extra typed words

hope this helps.

--------------------------------------------
On Thu, 21 Nov 2002 10:46:26 +0800, "Carlo Florendo" <carlo AT astra DOT ph>
wrote:

>Hello,
>
>Ever since I installed a newer cygwin, I've encountered problems which I
>didn't encounter before.  First, there was the
>"ls -l"problem which has not yet been resolved (and which is threaded as "ls
>problem" in this list.).  Just today, i discovered something wrong while
>using gcc.  I  compiled the snippet below and it's supposed to prompt me for
>input twice.  However, I only get prompted once.  (Using the visual c++
>compiler, the borland 5.5 compiler gives the correct results)

The reverse is true for the example below: ie you were encountering
problems before, but not realising it.

>My gcc version is 2.95.3-5.
>Cygwin version is The cygwin1.dll version I am using is
>1.3.15-cygwin-1-3-15-1.
>
>-----------begin snippet-------------
>#include <stdio.h>
>int main()
>{
>   int n;
>   char string[80];
>   for ( n=0 ; n<2 ; n++ )
>   {
>     printf( "Enter some words: " );
>     scanf( "%s", string);
>     printf( "The first word you entered is : %s\n", string );
>     fflush ( stdin );
^^^hint: "while('\n'!=getchar());"
>   }
>   return 0;
>}

You can't flush(stdin). Nothing wrong with Cygwin here, simply the other
compilers implementing stuff that isn't part of the language. The FAQ
for comp.lang.c or alt.comp.lang.learn.c-c++ will no doubt give you
ample insight.





----------------------
CHAUVIERE Jean-Raymond
06 80 38 01 14

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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