While doing a programming assignment in C++, I was trying to read data from a text file line by line using the following code snippet:
#include <fstream>
char line[2048];
ifstream in("data.txt");
in.getline(line,2048);
For some reason I was getting garbage being read from the file, but found out that the cause of the problem was the encoding of the text file. The text file I was using was Unicode. When I re-saved the file as ANSI encoding, the C++ program would then read the proper file data.
Saturday, November 29, 2008
Subscribe to:
Post Comments (Atom)





0 comments:
Post a Comment