🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #15753

Re: fflush(stdin) se me lo pasa por el forro?

#15753
From: Carles Sadurní Anguita
Date: Tue, 06 Jun 2000 00:00
67 lines
3234 bytes
El Mon, 05 Jun 2000 19:30:19 GMT, Ignacio Arenaza va escriure:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>>>>>> "s.romero" == Santiago Romero <compiler@jet.es> writes:
>
>    s.romero>  i�aki: he llegado en un programa a poner 3 scanfs
>    s.romero> seguidos:
>
>    s.romero>  scanf("%d", &numero); scanf("%s", nombre); scanf("%s",
>    s.romero> apellido);
>
>    s.romero>  eso, simplemente... y tras meter el numero se salta el
>    s.romero> del nombre y pasa directamente al apellido. En msdos
>    s.romero> poniendo un fflush(stdin) entre cada scanf() no se
>    s.romero> saltaba nada... LO MISMO PASA CON GETS y CON FGETS.
>
>Pues ahi va lo que tengo yo:
>
>    Script started on Mon Jun  5 00:04:35 2000
>    bash-2.03$ cat kk.c
>    #include <stdio.h>
>
>    int main (void)
>    {
>            int kk;
>            char buf1[200], buf2[200];
>    
>            printf ("Dame mas....\n");
>            scanf ("%d", &kk);
>            scanf ("%s", buf1);
>            scanf ("%s", buf2);
>    
>            printf ("kk=%d, buf1=%s, buf2=%s.\n", kk, buf1, buf2);
>            exit(0);
>    }
>    bash-2.03$ gcc -Wall -O2 kk.c -o kk
>    bash-2.03$ ./kk
>    Dame mas....
>    123 bu1 bufffer2
>    kk=123, buf1=bu1, buf2=bufffer2.
>    bash-2.03$ ./kk
>    Dame mas....
>    1243
>    nimbre
>    y_apellidos
>    kk=1243, buf1=nimbre, buf2=y_apellidos.
>    bash-2.03$ exit
>    
>    Script done on Mon Jun  5 00:05:24 2000
>
>Asi que o me envias el ejemplo que usas tu y no te funciona o ya me
>contaras...

Y si repites el proceso unas cuantas veces... con un while, digo.

Te env�o por email mi c�digo a ver si t� descubres el fallo (est� claro que
algo hago mal).

-- 
------------------------------------------------------------------------
Carles Sadurn� Anguita    |   no hab�a que cumplir promesas,
                          |   el cansancio era de placer,
Quita _mira_la_firma para |   las l�grimas eran de risas...
responder.                |   y parece que a�n fue ayer.
                          |           Los Suaves
------------------------------------------------------------------------
Technical Details
Message-ID: <slrn8jo9n7.10b.isard@localhost.localdomain>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <slrn8ifed1.190.nop_linux@compiler.linux.es> <87r9av1u79.fsf@eb2ebu.ampr.org> <slrn8iq65f.mk.compiler@compiler.linux.es> <87d7ma2t6m.fsf@eb2ebu.ampr.org> <slrn8jk6be.mc.compiler@compiler.linux.es> <87d7lxqew5.fsf@eb2ebu.ampr.org>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,d38036c26efcd863
X-Google-Attributes: gidf86c8,public
From: isard@localhost.localdomain (Carles Sadurní Anguita)
Subject: Re: fflush(stdin) se me lo pasa por el forro?
Date: 2000/06/06
Message-ID: <slrn8jo9n7.10b.isard@localhost.localdomain>
X-Deja-AN: 631875783
Content-Transfer-Encoding: 8bit
References: <slrn8ifed1.190.nop_linux@compiler.linux.es> <87r9av1u79.fsf@eb2ebu.ampr.org> <slrn8iq65f.mk.compiler@compiler.linux.es> <87d7ma2t6m.fsf@eb2ebu.ampr.org> <slrn8jk6be.mc.compiler@compiler.linux.es> <87d7lxqew5.fsf@eb2ebu.ampr.org>
Content-Type: text/plain; charset=iso-8859-1
X-Complaints-To: abuse@news.wanadoo.es
X-Trace: m2newsread.uni2.es 960324051 212.25.131.207 (Tue, 06 Jun 2000 22:40:51 MET DST)
Organization: CTV-JET@Uni2
Mime-Version: 1.0
User-Agent: slrn/0.9.5.7 (UNIX)
Reply-To: sadurni_mira_la_firma@jazzfree.com
NNTP-Posting-Date: Tue, 06 Jun 2000 22:40:51 MET DST
Newsgroups: es.comp.os.linux.programacion