Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binary File Input!!!

Status
Not open for further replies.

wearyweary

Programmer
Mar 23, 2001
4
Hey everyone,

I need to read in wav files for a program I'm working on.. If someone could post an example of opening a binary file with read permissions, and creating a buffer to store the whole file in (they are quite small) I would very much appreciate it.

Thanks a lot,

Eric
 
wait... I found another post on the same thing...

here it is

thread205-38842
 
One thing that I didn't mention in that post that I should have is that binary files are inherently non-portable, which is something anyone thinking of reading and writing the same file in different environments should take into account before deciding on reading/writing a file in binary mode.

This is due to endianness issues and the fact that implementations will insert padding bits in structs to force the members to align on certain byte boundaries. This is /very/ implementation dependent, so you could write a struct to a file in binary mode on one platform, use the same program and attempt to read the same file on another platform and get unexpected results.

Russ
bobbitts@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top