You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Tuesday, January 31st 2012, 12:25pm

Need help with reading file

Hello!

I need help. How i can read binary file?

First 8 byte - is a text (ascii), then float64, then int32, then float32*N (where N - previous int32) etc..

Can some one post code for this?

1) open file
2) read 8 byte (text)
3) read float64
4) read int32
5) read massiv float32 with length int32 (from #4)...

PS programm must be cross-platform.

2

Tuesday, January 31st 2012, 1:48pm

c++ is cross platform. you can use std::fstream to read from files.

You can use read http://www.cplusplus.com/reference/iostream/istream/read/ to read exact number of bytes.

in c++, we have double, float, int and char. You can extract these from a file stream using operator <<.

see here http://www.cplusplus.com/doc/tutorial/files/

This looks like a homework post, so I'm not oging to do it for you when you've made no effort ;)
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar threads