edit, create, delete, read file in a different directory??
I know i can use fstream to create, edit and read files in c++, i also believe there is a different way wich i am unfamiliar with. but is it possible to work with files NOT in the same directory as the program? like if the program is in C:\programfiles but i want it to append something to a file in C:\filesiwanttoalter. or what ever directory??
#include <iostream>
#include <fstream>
using namespace std;
Int main () {
ofstream a;
a.open ("C:\programs\fileneedschanges", ios::app);
a << "adding this to end of fileneedschanges";
a.close ();
return 0;
}
would do the trick? i was pretty sure it would not :-) btw why does a.close (); need the "()" when a.open does not??
I can't believe i asked that :D of course there is the ( and ) :D thanks
So double slashes? \\ and that's it? does it need a way to see the difference between the folders and the file, or does it just tawke the last one for a file?
EDIT: is cursing allowed in here? if not i am sorry.
Sorry I missed the question. '\' is used to escape characters such as '\n' is a newline as you may well no or '\a' is a bleep. Because it's a special escape character in string you must escape it if you wish to use one. Hence the double slash.
Ahh, that makes sense. i knew about the \n (yeah i know, that makes me a genious ;-) )
but i didn't realise that was it :D well then that was it, thank you for you patience.