Monday, May 24, 2010

How can I declare 8 floating point numbers in C programming language?

I need to write a C program tha reads 8 real (floating numbers) from another file (that contains the 8 numbers). Problem is, I can't figure out how to write my decaration statement to take into account the 8 values that i expect to display.


As in i don't know how to put in the form:


float variable-name.





Can someone help?

How can I declare 8 floating point numbers in C programming language?
You can declare them as array of 8 floating point nums right.. like


float num[8];





then read numbers into each number(I believe you got no problem in reading nums from file)





Note :: if file is binary file you can read entire data as a block





as fread(num,1, 8*sizeof(float),your_file_pointer);


No comments:

Post a Comment