Re: [Dev-C++] no read file-how to make default dir
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Carlos d. M. <cg...@wo...> - 2002-06-10 19:27:07
|
My executables write the files in its own directory.
For make a default dir you can add a variable which is the directory, for example:
default = "D:/Myapps/". [This would be inside a file you wrote in the exe's dir, see below]
used = default; The begin of the program
Then when you are asked for the file you want read/write you do:
cin >> (scanf("%s",) fileName;
Then you strcat it to the other,
strcat(used, fileName); (the used is for having default untouched)
fopen(used,
If you want to change the default:
if(youwantdoit)
cin >> default;
If you want change the current but not the default:
cin >> used.
And generate an only 1kb file with it:
file << default;
and file >> default at the begining,
so the next time it will maintain the default you set last time.
(of course this file is written in the exe's dir).
That's all.
|