Save Values on Exit C++ [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I've been working on a C++ program which gets values and saves them for later use. The problem for me is saving the data on exit, and initializing it on opening. How can I do this?

You can use a lib like pugixml to easily write the data on a xml file and read it on program startup.
On linux, you can register a "program exiting" callback with the atexit function, this is the perfect place to put your xml creation code. There is probably something similar to the atexit function on windows :)
Edit:
Another alternative, like #molbdnilo said, is to leave the file writing code in the end of the main function, which would not require using global variables to hold the data that needs to be written.

Related

The first function is called in MFC Aplication [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 days ago.
Improve this question
I'm new to MFC C++ and have a big MFC Project. It's in single document type and contains lots of classes such as doc.cpp, view.cpp, MainFrame.cpp ...Of course, It also contains lots of threads, functions in other classes. But i dont know exactly the way that project works, the way these threads are called. What is the first function, class is called? I try to find in default class of that project and have no clue.
I need an instruction or document explain step by step how a mfc project work. Can i have your help?

Declaring a variable which has a value in c++ or c that does not get destroyed when the program terminates [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How can I declare a variable or array that contain a value which does not get destroyed when the program terminates in c or c++?
When the process terminates, the kernel releases the resources owned by it. If you want to keep data/information obtained during the runtime of the process, you can use a database or the file system.
if you want to keep data after your process terminates, try storing it in a file.
check this for more:
file handling in C++

How to detect and communicate with another process under Linux? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I have a program 'P' and P is executed in terminal A. Let's call it process A. While process A is running, terminal B is opened and executes P as process B.
How can I make process A find process B and exchange data with each other? Someone told me to implement it with MPI but I haven't found any material telling me how.
I also appreciate that if anyone can tell me how to make these two process read and write the same variable (same address in memory). This solves my problem, too.
There are lots of options, but in most cases I think you'll find that named pipes/fifo will meet your needs.
See mkfifo, which creates a named pipe on the filesystem; that pipe can then be opened and accessed using standard open/read/write like a file for interprocess communications.

Can I run a DLL from an exe with parameters? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I would like to know if I can run a DLL function from a exe?
(C++ if it's important)
And If I can can I do it with parameters?
This isn't really code but the concept is the same
Run Calculator(time,0,int,max)
I would like to run something like that, using parameters to open up the dll in a certain way. Is it even possible?
Bonus Point for anyone who can give me an example in code :)
You can have just about any function you like in a DLL, and call it, just as you would call any library function. And have as many parameters as you like.

Using DLL in C++ Win32 applicaiton [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I have the library called Serial.dll that containts the file Serial.def that looks like this:
EXPORTS
ValidateSerial
GenerateSerial
I want to import the function GenerateSerial in my C++ Win32 application. I searched on the internet topics about using DLLs but I can't get the idea... Can anybody help me?
The info you provided only tells two funciton names. You can obtain their address doing LoadLibrary and GetProcAddress. But to make any use of them you need to know the proper signature, and the rules for the arguments and return values.
Without documentation (or a .h file) you can't go very far.