Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving txt information to the directory I want through if(of)stream

Status
Not open for further replies.

H3RO

Programmer
Jan 8, 2003
12
LT
Hi Guys!~ I'm using a litle troubles now reading txt data from one directory (ifstream) and saving it to the directory I want (ofstream). How am I supposed to read one's Tetst.txt file information and to copy it to the new file DoneTest.txt in the brand new directory which should be created simultaneusly copying data to the file DoneTest.txt which would be also created there. It is ok if the folder already exists, but what should be done if it's not??

Please correct me on what I have done wrong?

void main(){
ifstream read("C:\\Test.txt");
ofstream write("C:\\newDir\\DoneTest.txt");
string s;
while(getline(read,s))
write<<s<<endl;
}

P.S. is it ok to place source codes in here?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top