Hi All,
Im wondering why the bit of code isnt working ...
Basically its a simple function that takes a vector and a string. It is supposed to output the values in the vector to a. the screen and b. a file. It will write the vector's values to the screen alright but writes nothing to the file. What am I doing wrong?
Many Thanks
Code:string maketmpfile(vector<double> v, string &id) { double num; int i; ofstream a_file; if (id == "one"){ ofstream a_file ("dataone.txt"); } else { ofstream a_file ("datatwo.txt"); } for (i=0; i < v.size(); i++) { num = v.at(i); cout<<num; cout<<"\n"; a_file<<"num"; } a_file.close(); return tmpfilename; return 0; }