Re: i need help about Turbo C



"Tom St Denis" <tomstdenis@xxxxxxxxx> writes:
pipito wrote:
Hi...i am a beginner in C programming...
my question is like this...
im using the scanf in C to accept input data in output area,

printf("name: ");scanf("%s",name);

You need to add a "\n" or the printf won't always show. The stream is
only guaranteed to flush if you send a newline.
[...]

Another approach is to use fflush:

printf("name: ");
fflush(stdout);
fgets(name, sizeof name, stdin);

This isn't absolutely guaranteed to work, but it should work on any
system where this kind of interactive prompting makes sense.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: i need help about Turbo C
    ... im using the scanf in C to accept input data in output area, ... when i run the program, i use a spacebar in the input data, the ... age: 18 ...
    (comp.lang.c)
  • i need help about Turbo C
    ... im using the scanf in C to accept input data in output area, ... when i run the program, i use a spacebar in the input data, the ... name: pipito otso ...
    (comp.lang.c)
  • Re: Question about void pointers
    ... never found a reason to use it with scanf. ... I suppose (although printf() and scanf() are by no means mirror ... itself in a single string, we avoid any problems with funny formats. ...
    (comp.lang.c)
  • Re: why to use & in scanf( ) but not in printf( )
    ... note that printf() and scanfare not symmetric ... mean something quite different in scanf(), ... "maxlen" characters of the string. ... Reading email is like searching for food in the garbage, ...
    (comp.lang.c)
  • Re: definition of stdio.h
    ... define printf and scanf in a header (though it must also be fully ... Only an idiot or a completely macro-crazed bozo would define printf and ...
    (comp.lang.c)