input/output read and array

Hi folks,
I'm new to the site and have an input/output question. Given a file with the following sample data: 7 12.457826 13.877654 0.123456789 0.876548376 0.987776253 0.123847612 I'd like to read this external file and stuff arrays with the single integer and six floaters. What would be the most
efficient way to code this? Thanks, Ed
Why is this problematic? It's a simple for loop. Operator >> will deal with floats. Am I missing something? Ifyou don't know how to read a file, see the tutorial on this site.
Thanks for getting back to me. This site is so massive where exactly would I look for some type of paradigm for such input?
If you don't know how to deal with files at all, see http://www.cplusplus.com/doc/tutorial/files/
Oddly, this doesn't seem to show integer conversion..
Anyway, once you've opened a file,
1
2
3
4
5
int my_int;
float my_float[6];

my_file >> my_int;
for( int i = 0; i < 6; i++ ) my_file >> my_float[i];
Again, thanks - will take a look at that path...
Topic archived. No new replies allowed.