Noob fstream question

Can someone please provide me with code of simply opening an existing file (lets say a .txt on the desktop) to edit?

I've reviewed this sites (along with other sites') file input/output tutorials, but I'm having some trouble avoiding compiling errors.

As you can see, I'm total noob. I just get so frustrated with the simplicity of the task, I can't figure it out!

When I try to specify the file path
("C:\Documents and Settings\Administrator\Desktop\file.txt" for example)
of the existing file, it ends up creating a new file in the compilers project folder with the name being the file path itself (DocumentsandSettingsAdministratorDesktopfile.txt)!
To have a \ you should use \\ as in C++ it is used for escape character but also a / would work, so change the path to
"C:\\Documents and Settings\\Administrator\\Desktop\\file.txt"
or
"C:/Documents and Settings/Administrator/Desktop/file.txt"
Thanks :)

I don't suppose opening an application would be done the same way as opening a text file to edit it? ..like a command from cin to open a batch file for example?
Last edited on
If you want to call something as with the command line you can use system("command"); ( http://www.cplusplus.com/forum/articles/11153/ ) or external libraries functions
oh nice :O
..handy lol

Topic archived. No new replies allowed.