Reading contents from an .raw file in c++

Home Forums C Programming Reading contents from an .raw file in c++

This topic contains 0 replies, has 1 voice, and was last updated by  DanutaWilber 10 years, 1 month ago.

  • Author
    Posts
  • #2154

    DanutaWilber
    Member

    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; }

You must be logged in to reply to this topic.

Share
Tweet
Share
Pin
+1