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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem reading block of data from file

Status
Not open for further replies.

mrhegemon

Programmer
Jul 3, 2003
20
US
I want to read a block of data from an ifstream into an array of doubles. However, the function .read(char* buffer, int size) does not allow me to put the pointer for the double array into where it requires a char pointer. I don't understand why there is this limitation, or how to get around it. I could use C-style file reading functions but I hate to mix C++ streams with C files.
 
The buffer that the read function is looking for can really be anything you need it to be. A lot of built in functions that take some data buffer of an unknown type will typically declare the variable as a char *. Pass your array of doubles to the function and cast it as char * and it should work. The size variable should be the total size of your array, i.e. sizeof(mydoublearray).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top