• Welcome to Valhalla Legends Archive.
 

ofstream/ifstream

Started by MoNksBaNe_Agahnim, December 11, 2003, 08:06 PM

Previous topic - Next topic

MoNksBaNe_Agahnim

i was wondering, how would i create/input info/output info from a txt file from a folder...

i.e.


ofstream fout;

fout.open("text.txt");

fout << "testing";

fout.close();


that would make a file called text.txt in my main program folder and input testing in the file...how would i do that if i wanted to create a file into a folder within the main folder and write into it? Would it be that same only...


ofstream fout;

fout.open("txt files"); // folder already been made called txt files

fout.open("text.txt");

fout << "testing";

fout.close("text.txt");

fout.close("txt files");

Eibro

Quote from: MoNksBaNe_Agahnim on December 11, 2003, 08:06 PM
i was wondering, how would i create/input info/output info from a txt file from a folder...

i.e.


ofstream fout;

fout.open("text.txt");

fout << "testing";

fout.close();


that would make a file called text.txt in my main program folder and input testing in the file...how would i do that if i wanted to create a file into a folder within the main folder and write into it? Would it be that same only...


ofstream fout;

fout.open("txt files"); // folder already been made called txt files

fout.open("text.txt");

fout << "testing";

fout.close("text.txt");

fout.close("txt files");

Close, just specify the directory when creating the file:

fout.open("text files\\text.txt");
fout << "testing";
fout.close();
Eibro of Yeti Lovers.