I was wondering if it would be possible to open up the last used file whenever my prog starts?
Printable View
I was wondering if it would be possible to open up the last used file whenever my prog starts?
Here's an easy way round that:
save the name of the last used file name when the program ends in another file and hence open the last used file.
I should write a book:
"Practical Thinking From A Noob To A Noob"
i keep getting this message "..." undeclared [first use this function]. What does it mean by that???
I got the nameof last used file output sorted but how do i get my prog to search for that file and open it???
read into the saved name of the file with a string and then use that exact string to open the file...just like you got a user to enter the name into a string.
I just get an error when i try to do that so heres my code tell me whats going wrong:
Code:ifstream d_file("Txt_log.txt");
getline(cin,txt);
ifstream e_file(txt);
getline(cin,txtt);
cout<< txtt;
could someone tell me wahts the matter with the code above?
Try that...Code:ifstream d_file("Txt_log.txt");
getline(cin,txt);
ifstream e_file(txt.c_str());
getline(cin,txtt);
cout<< txtt;
well im kinda a newb too... but it looks to me that you have to do this
From your code... your using getline as to get input from the user... that what CIN buffer is for...Code:ifstream d_file("Txt_log.txt");
getline(d_file,txt);
ifstream e_file(txt.c_str());
getline(e_file,txtt);
cout<< txtt;
But if you want to get input from a file... u use the file name instead, as the buffer...
Still not working, thanx though.
Can someone plz help me?????
Possibly if you show the code that doesn't work.Quote:
Originally Posted by L_U_K_E
Kurt
yes... what specifically isn't working?
Could someone ave a lokk at this code im trying to make it copy the text from one file and paste it into another...
Code:cout<<"Please enter the directory and filename and extension: ";
getline(cin,x);
ifstream a_file(x.c_str());
getline(a_file,a);
cout<<"Please enter the directory and filename and extension of the second file: ";
getline(cin,c);
ofstream b_file(c.c_str(),ios::app);
cout<< a;
cin.get();
cin.get();
system ("cls");
break;
if you change
toCode:cout<< a;
this program would append the first line of a_file to b_file.Code:b_file<< a;
Kurt