c programming question

Doug Gwyn gwyn at smoke.BRL.MIL
Sun Aug 5 11:17:59 AEST 1990


In article <Aug.4.14.20.02.1990.4835 at elbereth.rutgers.edu> shmehta at 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.



More information about the Comp.std.c mailing list