Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Quick n00by question... (http://www.programmingforums.org/showthread.php?t=8066)

jobobshishkabob Jan 22nd, 2006 7:50 PM

Quick n00by question...
 
Well if you've read my posts before, i am a noob...

just a quick question...

I want to cout<<"Press any key to Enter";
or cout<<"Press Enter/Return to Enter";

and the cin>> ent; should launch a file which is located at ./prgm/ddww.exe


how do i do that???

i need to know this because i'm having bad luck with batch files... thanks.

jayme Jan 22nd, 2006 7:56 PM

You're having trouble double clicking a batch file? Opening a batch this way has the same effect as clicking on it. Well here it is anyways:

:

#include <iostream>
using namespace std;

int main()
{
cout << "Press enter.";
cin.get();
system("start c:/myprogram.exe"); //A bat file has .bat extension by the way, not an exe.
return 0;
}


InfoGeek Jan 22nd, 2006 7:58 PM

you can use system function call.
:

system("./prgm/ddww.exe");

jobobshishkabob Jan 22nd, 2006 8:28 PM

thank you both.

does any one know how to make both files open in the same window?

jobobshishkabob Jan 22nd, 2006 8:34 PM

what?????

this isnt working. its bring me the same results as the batch files...

all my pages are different .exe's

and if i open the "ddww.exe" through something else, like a .bat file or this exe, its closing at the time i open a page...

what ever im just going to mix the 2 pages. thanks for the help.

Cache Jan 23rd, 2006 1:12 AM

For a batch file, use the 'Call' command: Call some.exe

Although I'm wondering what you mean by "pages". Whatever it is you're after doing, there is probably a better way to achieve it than through calling multiple executables with a batch file.

teencoder Jan 23rd, 2006 11:03 AM

Try running your program through the console it shouldn't disappear that way.

Polyphemus_ Jan 23rd, 2006 11:53 AM

Put system("pause"); in your code, just before it returns.

DaWei Jan 23rd, 2006 6:12 PM

Better than a system call (non portable), put a statement that's part of the standard library that requires input from the user. Discard the input and move on to termination.

weeb0 Jan 24th, 2006 12:25 PM

add a pause at the end of the batch file.


All times are GMT -5. The time now is 9:27 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC