[comp.std.c] c programming question

shmehta@elbereth.rutgers.edu (Shreefal Mehta) (08/05/90)

i hope this is the right newsgp to post to; i went by the title as
there was no news to be read in the newsgp. i guess either this means
that no one writes to this gp in which case no one reads either, or
that my machine does not receive the newsgp..

Any way, my question is simple. i want to read in three Floating POint
numbs. i can either read them in from a file or i can type them in. i
foundout that i can't do 'getchar.' So how can i read in the data to
three variables. 
THank you

shmeht@elbereth.rutgers.edu
mehta@orca.rutgers.edu
-- 
----------------------------------------------------------------------------- 
- When you get to the end of your rope, tie a knot and hang on. And swing!!
							Leo Buscaglia
------------------------------------------------------------------------------

gwyn@smoke.BRL.MIL (Doug Gwyn) (08/05/90)

In article <Aug.4.14.20.02.1990.4835@elbereth.rutgers.edu> shmehta@elbereth.rutgers.edu (Shreefal Mehta) writes:
>i hope this is the right newsgp to post to; i went by the title as
>there was no news to be read in the newsgp. i guess either this means
>that no one writes to this gp in which case no one reads either, or
>that my machine does not receive the newsgp..

I don't know what it means at your site, but this newsgroup is intended
for discussions about the C standard.  General discussion and questions
about C should be posted to comp.lang.c (INFO-C Internet mailing list),
which is where I have directed follow-ups.

>Any way, my question is simple. i want to read in three Floating POint
>numbs. i can either read them in from a file or i can type them in. i
>foundout that i can't do 'getchar.' So how can i read in the data to
>three variables. 

If they are stored in character format, as I suspect from the mention
of typing them in, use scanf() or fscanf() to read them and convert them
into internal floating-point representation.

If they were stored in binary format corresponding to their internal C
floating-point representations, you could use fread() to "roll them into"
internal floating-point variables of the same size.

Any good introductory C programming book should explain this.  Kernighan
& Ritchie's "The C Programming Language" is recommended.