![]() |
|
#1
|
|||
|
|||
Getting float data from text file to arrayHello
I am a newbie to C language. I need to use the data (48 values) from a text file (which area float values) in the following form: 80.00 23.00 82.00 22.00 80.00 23.00 81.00 24.00 80.00 22.00 80.00 23.00 84.00 24.00 80.00 22.00 82.00 32.00 120.00 102.00 120.00 132.00 120.00 140.00 120.00 150.00 110.00 141.00 120.00 128.00 110.00 118.00 105.00 100.00 105.00 87.00 80.00 38.00 82.00 30.00 80.00 23.00 78.00 22.00 80.00 22.00 79.00 22.00 I need this data to form an array which i could use for further work. I have worked out the following program but it gives 0.000000 (48 times) only. I am using CodeBlocks open source IDE/compiler on windows XP. My present program is as follows: CPP / C++ / C Code:
Thanks & Regards Ali Last edited by LuciWiz : 02-Jun-2009 at 02:28.
Reason: Please insert your C code between [cpp] & [/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: Getting float data from text file to arrayQuote:
The fread() function reads binary values, (bytes that make up floating point numbers in machine representation). To read the values that are expressed as characters in a text file, you can make a loop that reads the values with fscanf(). Maybe do something like: CPP / C++ / C Code:
Regards, Dave |
|
#3
|
|||
|
|||
Re: Getting float data from text file to arraythanks Dave.. it solved the problem
|
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Power Calibration Error In Nero Fix (hopefully) | matt3678 | Computer Hardware Forum | 60 | 20-Aug-2009 06:04 |
| CD Burner Help - Power Calibration Error.... | JonBoy420 | Computer Hardware Forum | 111 | 19-Feb-2009 04:54 |
| Canny edge detector | Skm | Java Forum | 1 | 01-Jan-2006 07:51 |
| How to read unknown total of int data from text file to a 2-dim array in C or C++? | ladyscarlet99 | C Programming Language | 2 | 09-Sep-2005 15:07 |
| How to search a huge text file for data? | JdS | MySQL / PHP Forum | 7 | 27-May-2003 10:27 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The