I have a few std::vector
of length N
with long, string, double
types. I am trying to write it to a plain text file this way:
int N = 100;
std::vector<std::string> var1String(N), var2String(N), var3String(N), var4String(N);
std::vector<long> var1Long(N);
std::vector<double> var1Double(N);
...
std::ofstream f(path2file);
for(int i=0; i<N; i++)
{
f << var1String[i] << " " << var2String[i] << " " << var1Long[i] << " " << var3String[i] << " " << var1Double[i] << " " << var4String[i] << std::endl;
}
although I am not using the ios::binary flag
it gets written in binary which I can easily read in linux. However I want to write it into a plain ASCII text file. (Note: I've also tried converting the var1Long[i]
and var1Double[i]
to strings without making any difference). What am I doing wrong?
EDIT: It is part of a larger program that gets some outputs from a server to the vectors in ASCII. As I said, when reading teh binary with linux or running the program using std::cout
instead f
it prints just fine. I just do not understand what might be causing the stream to be passed as binary.