io with files

closed account (y0XSE3v7)
Can anyone tell me where text files are saved when I create one in a console application, if I am wrong and I have to create the file where do I save the file for my application to be able to read from and write to it?

To current working directory. http://en.wikipedia.org/wiki/Working_directory
This depends on how you're running this program. Are you running this program from the command line, clicking an icon on the desktop, or through an IDE?

closed account (y0XSE3v7)
Thanks guys I found it, turns out the text file hast to bee in the same directory of the executory file so I just created my text file there works fine but for some reason it only writes to file when I run the program from the exe file in that same directory it doesnt write anything when I run the application in codeblock editor.
it doesnt write anything when I run the application in codeblock editor
Most likely it does still write to the output file, but the file itself is placed in a different location. i.e. it will be found in the current "working directory". Probably that will be the same as the location of the source .cpp files.
http://stackoverflow.com/questions/143174/how-do-i-get-the-directory-that-a-program-is-running-from
the directory your program was started from. This is distinct from the directory that holds the current executable program file. It isn't necessarily the same directory; if someone runs the program from a command prompt, then the program is being run from the command prompt's current working directory even though the program file lives elsewhere.

As example, a Windows shortcut has "Start in" property; it can dictate cwd. Codeblock probably dictates too.

You know the name of the file, so you can search your entire computer for that filename with Windows Explorer.
Topic archived. No new replies allowed.