Automatically closing
Ok, over the past 12+ hours i''ve been sweating my ass of with C++ (that includes like 10 hours sleep), and i''m really stuck. When I compile my programs, they open and shut right away. I''ve tried the "system("PAUSE");" code, and it isn''t making any difference. I''m sorry if i''m getting on your nerves but once I get better i wont ask as many questions, but i''ll still chill here (if i''m not banned for being annoying).
You see, in scotland, we call something like this "Taking the piss".
So, can anyone help me, PLEASE? I''m running xp, if that makes any difference (?). Hope to hear from y''all soon, and thanks alot for your time.
Ass up high, make a mother fu**er cry help me stay aliv.the time is right i wanna feel it good 'n' tight i'm going to do this alone i'm gonna feel it upright.
Hi
try putting some function that waits for user input, like getch(), at the end of the program
Runicsoft -- home of my open source Function Parser and more
try putting some function that waits for user input, like getch(), at the end of the program
Runicsoft -- home of my open source Function Parser and more
Ok, now me=seriously PISSED.
It wont work, i tried putting it after the compound statement, then at the bottom of the compound statement, and it isnt working. Why the HELL does this only happen with my computer? Everyone else but me can run it fine. I really hate XP.
It wont work, i tried putting it after the compound statement, then at the bottom of the compound statement, and it isnt working. Why the HELL does this only happen with my computer? Everyone else but me can run it fine. I really hate XP.
Ass up high, make a mother fu**er cry help me stay aliv.the time is right i wanna feel it good 'n' tight i'm going to do this alone i'm gonna feel it upright.
If you are using the Dev C++ software from Bloodshed, I am getting the exact same thing. While doing the tutorials, the black box just flashes on screen.
No, man, i''m using Borland . I was using dev C++ up untill last night and this is the reason I changed, but it still automatically closes. Come on, some C++ experts MUST know how to fix it...:-/
Ass up high, make a mother fu**er cry help me stay aliv.the time is right i wanna feel it good 'n' tight i'm going to do this alone i'm gonna feel it upright.
I tried a test console program under Win2k and it seems that system("pause") does nothing. Crappy solution time (file it under "hey, at least it works")...
Start up the MSDOS command box (start->run, type "cmd" (no quotes) or find it somewhere in start->programs or start->programs->accessories).
Change to the directory containing the exe file (using the good ol' "cd" DOS command -- just ask about it if you haven't used it before). Type the name of the exe file for your program. It will run the program and you'll see the output in the DOS box . Whenever you want to repeat the process, hit the up arrow key to get the last command (which will be the name of your exe).
You can also use some input thing to stop it - for example, getch() as suggested or std::getline(). I don't have a c++ compiler installed under 2K, so the following may have incorrect syntax. Try it anyway:
Something along those lines. That should force the thing to wait for you to enter a variable and hit return.
[edited by - Alimonster on October 13, 2002 9:00:56 AM]
Start up the MSDOS command box (start->run, type "cmd" (no quotes) or find it somewhere in start->programs or start->programs->accessories).
Change to the directory containing the exe file (using the good ol' "cd" DOS command -- just ask about it if you haven't used it before). Type the name of the exe file for your program. It will run the program and you'll see the output in the DOS box . Whenever you want to repeat the process, hit the up arrow key to get the last command (which will be the name of your exe).
You can also use some input thing to stop it - for example, getch() as suggested or std::getline(). I don't have a c++ compiler installed under 2K, so the following may have incorrect syntax. Try it anyway:
#include <iostream>#include <string>using namespace std;int main(){ cout << "Hey, did you know that I'm Scottish too?" << endl; string dummyVar; getline(cin, dummyVar); cout << "You typed " << dummyVar << endl; // just for kicks return 0;}
Something along those lines. That should force the thing to wait for you to enter a variable and hit return.
[edited by - Alimonster on October 13, 2002 9:00:56 AM]
Thats it...i give up. The only way I can get my programs to work is by using cmd. It''s justnot worth learning it. If I wanted to make a game, i''d have to go to cmd every time I wanted to use it. Biggest load of bollocks ever.
Ass up high, make a mother fu**er cry help me stay aliv.the time is right i wanna feel it good 'n' tight i'm going to do this alone i'm gonna feel it upright.
Chill the hell out.
You''re compiling it as a CONSOLE mode program - don''t be upset when it only runs in the console!
ANY console mode program behaves in the same way if you double-click it to start it.
Learn Win32 if you want to program with windows, and console mode if you want to code console mode apps.
www.coldcity.com
code, pics, life
You''re compiling it as a CONSOLE mode program - don''t be upset when it only runs in the console!
ANY console mode program behaves in the same way if you double-click it to start it.
Learn Win32 if you want to program with windows, and console mode if you want to code console mode apps.
www.coldcity.com
code, pics, life
[size="2"]www.coldcity.com code, art, life
five, try posting your code on here.. and people will tell you what you are doing wrong (if anything)
use "source" and "/source" tags (enclosed in []) around your code and people will be able to point it out. Failing that, do you have a messenger, like Yahoo or AIM, I would be willing to give you a hand. quentin17_98 on Yahoo or Englishman02 on AIM.
[edited by - hammerstein_02 on October 13, 2002 9:38:05 AM]
[edited by - hammerstein_02 on October 13, 2002 9:38:46 AM]
use "source" and "/source" tags (enclosed in []) around your code and people will be able to point it out. Failing that, do you have a messenger, like Yahoo or AIM, I would be willing to give you a hand. quentin17_98 on Yahoo or Englishman02 on AIM.
[edited by - hammerstein_02 on October 13, 2002 9:38:05 AM]
[edited by - hammerstein_02 on October 13, 2002 9:38:46 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement