So I was wondering if the file type makes a difference or if the way you are opening the file matters.
Everything is in separate functions, I have all the #includes
BTW running and compiling through the unix shell on a Knoppix live CD. Using Gedit for writing c/c++ and using a make file given to us for the project to compile.
This Works for a text file.
But changing fstream to ifstream, it freezes
fstream myfile (filename.c_str());
if (!myfile) {
//Do Stuff
}
//Do Other Stuff
myfile.close();
This Doesn't Work for reading in a .tif image file. This gives me junk values upon output.
fstream imfile (filename.c_str(), ios::binary);
if (!imfile) {
//Do Stuff
}
This works for a .tif image file and returns proper output.
ifstream imfile; imfile.open (filename.c_str(), ios::binary);
Just if anyone was wondering, for reading the .tif files this is the very next thing after opening the file with the above code
imfile.seekg (0, ios::beg); imfile.read (line,2); imfile.read ((char *)&line2,2); imfile.read ((char *)&line3,4); imfile.seekg(line3,ios::beg); imfile.read((char*)&line4,2); imfile.close(); line[2]='\0'; cout << line << "\n"; cout << line2 << "\n"; cout << line3 << "\n"; cout << line4 << "\n";
So reading in the information from the .tif file is exactly the same, printing out from the .tif file is exactly the same. So I don't understand why one works and the other doesn't.
If I didn't explain well enough let me know. Thanks

New Topic/Question
Reply
MultiQuote









|