By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

accessing memory directly from C++

P: n/a
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

Feb 20 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
* ra********@gmail.com:
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.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Feb 20 '07 #2

P: n/a
On 19 Feb 2007 19:45:06 -0800, ra********@gmail.com wrote in
comp.lang.c++:
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 news:comp.os.ms-windows.programmer.win32

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Feb 20 '07 #3

P: n/a

Jack Klein wrote:
>
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/
Feb 25 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.