Interaction between two programs

D

Denis Remezov

Sean said:
I'm sure this might be a simple questions, but here it goes anyway. I
am trying to do a 'front end' to a program. For example I have a
program that doesn't take command line arguments, but prompts the user
for input every time it is run, ie. Enter your name:

I want to run a program that will automatically type the name into
that field. I just don't really know where to start. Is this
suppossed to be a spawn or an exec? I saw something about pipes, but
didn't quite get it. Please explain for me.

This is NOT for a class, just trying to learn how to do things


You could possibly make the use of the following:

Both C++ and C define three "standard streams": stdin, stdout and stderr.
The type of these expressions is FILE*, and they are required (I think;
need to double-check) to be open at the program start-up. See <stdio.h>
or <cstdio>.
The C++ objects cin, cout and cerr use the respective standard streams as well.

Now, what is hiding behind each of the standard stream depends on the way
the program was started (they could be attached to the terminal, to files,
to streams of another program, etc.). This part, however, is indeed system
dependent. One thing that is standard is the system() function, but its
behaviour is again system dependent.

Denis
 
S

Sean

I'm sure this might be a simple questions, but here it goes anyway. I
am trying to do a 'front end' to a program. For example I have a
program that doesn't take command line arguments, but prompts the user
for input every time it is run, ie. Enter your name:

I want to run a program that will automatically type the name into
that field. I just don't really know where to start. Is this
suppossed to be a spawn or an exec? I saw something about pipes, but
didn't quite get it. Please explain for me.

This is NOT for a class, just trying to learn how to do things
 
B

bartek

(e-mail address removed) (Sean) wrote in @posting.google.com:
I'm sure this might be a simple questions, but here it goes anyway. I
am trying to do a 'front end' to a program. For example I have a
program that doesn't take command line arguments, but prompts the user
for input every time it is run, ie. Enter your name:

I want to run a program that will automatically type the name into
that field. I just don't really know where to start. Is this
suppossed to be a spawn or an exec? I saw something about pipes, but
didn't quite get it. Please explain for me.

This is NOT for a class, just trying to learn how to do things

Your question has nothing to do with C++. It is off topic in this
newsgroup.

It is also very platform specific, though you don't even specify what
platform implementation you're interested in.

For unix, see Ask about pipe/popen, fork and exec.

For windows, see Ask about CreatePipe, CreateProcess etc...

Cheers.
 
J

JKop

Sean posted:
I'm sure this might be a simple questions, but here it goes anyway. I
am trying to do a 'front end' to a program. For example I have a
program that doesn't take command line arguments, but prompts the user
for input every time it is run, ie. Enter your name:

I want to run a program that will automatically type the name into
that field. I just don't really know where to start. Is this
suppossed to be a spawn or an exec? I saw something about pipes, but
didn't quite get it. Please explain for me.

This is NOT for a class, just trying to learn how to do things


This is a C++ newsgroup, no more no less. We conversate about C++ here. We
don't mention a word about platforms. You may find this a bit hard to
imagine, but think about things like: Encrypting Data, Encoding an MP3. Both
these processes are platform independant.


C++ is used to write programs for anything. A C++ compiler generates machine
code, which can be a Windows program, or the interface for your brand new
microwave, or the menus on your mobile phone.
Therefore, we don't talk about two programs running at once here in this
newsgroup. You're going to have to go to a very platform specific newsgroup
to talk about this. I myself am familiar with Win32 programming, so... if
the programs you're writing are Win32, then here's one way of going about
it:

First make your first program, into which you enter your name. You're done
with the first program now.

The trick is in writing the second program. I suggest that you use the
function "FindWindow" or a similar Win32API function that can be used to
obtain some sort of handle to the other program. Once you've got some sort
of handle, you use more Win32API functions to send information and/or
manipulate the first program. You'll most likely use the Win32 function
"SendMessage" for this.

Further questions on this subject to:

News Server: msnews.microsoft.com
Newsgroup: microsoft.public.win32.programmer.kernel

Note that the above newsgroup isn't language specific, so don't post any
code. People will simply tell you which Win32 function to use and in what
way. Make sure you tell them it's a console application.


Hope that helps.


-JKop
 

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,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top