- This topic has 0 replies, 1 voice, and was last updated 16 years, 1 month ago by .
Viewing 0 reply threads
Viewing 0 reply threads
- The forum ‘C Programming’ is closed to new topics and replies.
Home › Forums › C Programming › Reading contents from an .raw file in c++
Hello
I am currently working on a project where i have a block.raw file. I am at the point where i can open the file, but i am having trouble reading the contents correctly. i am trying to read the contents one unsigned character at a time, but i get different results each time i do it. Any help is appreciated! Thnx in advanced.
int main()
{
unsigned char letter;
ifstream indata; // indata is like cin
ofstream outdata;
outdata.open( “contents.txt” );
indata.open( “block.raw” ); // opens the file
if( !indata )
{ // file couldn’t be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
while ( !indata.eof( ) ) {
indata >> letter;
cout << letter;outdata << indata;//indata >> letter;
}
cout << endl;indata.close();cout << "End-of-file reached.." << endl;return 0;}