Original Post
When I open a file and start reading from it the stream fails when it reads characters it apparently does not like. I was under the impression that the read function did not care what the data meant and only transfered bytes around. In particular it fails when it encoutners 0x1A. However if you open the file in binary mode everything works fine. I am just wondering if anyone has a technical explination? Simple Example of the working version:
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ifstream file;
file.open("test.txt", ios::binary);
if(file.is_open())
cout << "file opened" <<endl;
char buff;
//while(file >> buff)
// cout << buff;
while(file.read((char*)&buff,1))
cout << buff;
return 0;
}