accessing memory directly from C++

R

rajangamsj

Hello all,
I have a C++ program (prog1) which does some some actions and uses
array for it. The start address of the array is known once the program
is run.

Now I have another independent program(prog2) which needs to
access the same array used by prog1 and do some set of actions (like
display the contents etc). It is not possible/desiarable to have both
these programs as part of a single exe file. They need to be in 2
different exe files.

Is there any which this could be made possible?? We tried writing
the address to a file in prog1 and read it from prog2, but we are
unable to assign the content in the file to a pointer variable in
prog2.

Regards,
Rajangam
 
A

Alf P. Steinbach

* (e-mail address removed):
I have a C++ program (prog1) which does some some actions and uses
array for it. The start address of the array is known once the program
is run.

Now I have another independent program(prog2) which needs to
access the same array used by prog1 and do some set of actions (like
display the contents etc). It is not possible/desiarable to have both
these programs as part of a single exe file. They need to be in 2
different exe files.

Is there any which this could be made possible?? We tried writing
the address to a file in prog1 and read it from prog2, but we are
unable to assign the content in the file to a pointer variable in
prog2.

The C++ language and its standard library does not provide any means of
interprocess communication.

How to do that depends on your OS and so is off-topic in [comp.lang.c++].

Since you mention "exe" you're probably using Windows, and if so then
you might try posting in [comp.os.ms-windows.programmer.win32], or see
this group's FAQ for some other possibly relevant groups.
 
J

Jack Klein

Hello all,
I have a C++ program (prog1) which does some some actions and uses
array for it. The start address of the array is known once the program
is run.

Now I have another independent program(prog2) which needs to
access the same array used by prog1 and do some set of actions (like
display the contents etc). It is not possible/desiarable to have both
these programs as part of a single exe file. They need to be in 2
different exe files.

Then there is absolutely nothing at all in the standard C++ language
that can help you. There is no concept of "another executable" in the
language defined by the standard.
Is there any which this could be made possible?? We tried writing
the address to a file in prog1 and read it from prog2, but we are
unable to assign the content in the file to a pointer variable in
prog2.

There is probably a way to do this with non-standard extensions
provided by your operating system and compiler, but you need to ask in
a group that supports your particular compiler/OS combination.

At a guess, try
 
G

Grizlyk

Jack said:
There is probably a way to do this with non-standard extensions
provided by your operating system and compiler, but you need to ask in
a group that supports your particular compiler/OS combination.

At a guess, try news:comp.os.ms-windows.programmer.win32

Also see POSIX IPC functions.

--
Maksim A. Polyanin
http://grizlyk1.narod.ru/cpp_new

"In thi world of fairy tales rolls are liked olso"
/Gnume/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top