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

Viewing 0 reply threads
  • Author
    Posts
    • #2154
      DanutaWilber
      Participant

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

Viewing 0 reply threads
  • The forum ‘C Programming’ is closed to new topics and replies.