|
-
Sep 14th, 2000, 01:54 AM
#1
How do i save a variable called pass to a file, and how do i load that variable back into the prog from the file?
-
Sep 14th, 2000, 02:34 PM
#2
Monday Morning Lunatic
How about something like:
Code:
char *pcPass = "MyPass";
ofstream OutFile("OutFile.dat");
if(!OutFile.fail()) {
OutFile << pcPass;
}
OutFile.close(); // This is automatic when it goes out of
// scope, but used here so we can open it
// again
string sPass;
ifstream InFile("OutFile.dat");
if(!InFile.fail()) {
InFile >> sPass;
}
InFile.close()
This may not be perfect, but it's sort of the idea.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 14th, 2000, 03:59 PM
#3
Ok, i got that working, but how do i get the folder that the file is currently residing in?
-
Sep 14th, 2000, 04:04 PM
#4
Monday Morning Lunatic
What do you mean? You want to search the HD for the file? Or the folder the app is in?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 14th, 2000, 04:09 PM
#5
I have the File and the App in the same folder, but i need to find the path of the file. I want to do that so the App can be stored in any folder.
-
Sep 14th, 2000, 04:16 PM
#6
Monday Morning Lunatic
Confused here...
The path will be wherever it is saved...you can also open a file using:
Code:
ofstream Out("c:/dir/file.ext");
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 19th, 2000, 12:49 PM
#7
Frenzied Member
What he wants......
he wants to know how to get the path that the application is currently in, the c++ equivelent to App.Path in VB.
-
Sep 19th, 2000, 01:14 PM
#8
Monday Morning Lunatic
In a windows app, use GetModuleFileName, with the hInstance of your app. For console programs, the program name is supplied as argv[0] in your main function, if it's defined like this:
Code:
int main(int argc, char **argv) {
...
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|