fseek(f1, 0, SEEK_END);
long Size = ftell(f1);
rewind(f1);
buffer=(char*) malloc(Size);
if(buffer==NULL){
cout <<"Memory allocation has failed!");
return 0;
}
size_t result = fread(buffer, 1, Size, f1);
if(result!=Size){
cout << "Error while reading the file!";
return 0;
}
Could someone tell me why this code works well if there is no break line in the txt file but when I write '\n' to a text file it gives me the error: "Error while reading the file!". I've been trying to figure it out for a longer while now but it nothing really makes sense to me...