Re: Getting user input in Linux?



[Please don't top post and snip content and sigs where possible.]

Manik <manik.mayur@xxxxxxxxx> writes:
Zach wrote:
I run Linux 2.6.18 and am seeking a way in C to get user input. I want
them to have the chance to enter a value and have it assigned to a
variable.
<snip>
How about,

int s1;
printf("Enter first integer:");
scanf(&s1);

Won't compile (if you are lucky). Better:

int s1;
printf("Enter first integer: ");
fflush(stdout);
scanf("%d", &s1); /* scanf needs a format */

--
Ben.
.



Relevant Pages

  • Re: size_t problems
    ... assigned to a 32 bit int. ... Clearly with strlenthe chance of it being an error is negligible. ... And I think this is true other size_t->int assignments. ... I doubt that the chance a string is longer than 2GB is always ...
    (comp.lang.c)
  • Re: Initialising Variables
    ... Okay, ... int func ... Where you *know* t does not have a chance of even being used before ...
    (comp.lang.c)
  • Re: 0a appending w/strcpy
    ... >>int main ... > I'm getting here I might have a chance at not sucking in a couple ...
    (comp.lang.c)
  • Re: VS2005 doesnt like its own suggestions
    ... Is this by chance part of MS' holy wars against ISO C++ ... INT which are identical to bool & int? ... David ... > Don't know about the VS2005 compiler, ...
    (microsoft.public.vc.language)
  • Re: printf("%d",*(&ptr2 + 2))
    ... What it prints is purely by chance. ... Did your compiler not produce a warning? ... It expects an int. ...
    (comp.lang.c)