![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jan 2006
Location: Texas
Posts: 36
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 | |
|
Professional Programmer
|
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;
}
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Jun 2005
Location: India, The great.
Posts: 435
Rep Power: 4
![]() |
you can use system function call.
system("./prgm/ddww.exe");
__________________
PFO - My daily dose of technology. |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Jan 2006
Location: Texas
Posts: 36
Rep Power: 0
![]() |
thank you both.
does any one know how to make both files open in the same window? |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Jan 2006
Location: Texas
Posts: 36
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#6 |
|
Hobbyist
Join Date: Sep 2005
Posts: 259
Rep Power: 3
![]() |
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. |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
Join Date: Jul 2005
Posts: 158
Rep Power: 0
![]() |
Try running your program through the console it shouldn't disappear that way.
__________________
Geeks may not be cool now but in the long run they prosper. |
|
|
|
|
|
#8 |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 3
![]() |
Put system("pause"); in your code, just before it returns.
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#10 |
|
Newbie
Join Date: Jan 2006
Posts: 17
Rep Power: 0
![]() |
add a pause at the end of the batch file.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|