Advertisement

Need some help with C++.....

Started by May 31, 2002 04:57 PM
6 comments, last by Xeract 22 years, 5 months ago
Hey, I am trying to learn C++, andI am having a problem where everything is fine until i run the program, then the screen quickly flashes up for a split second and i can see the program, then it disapears again. No matter what i do i cant get it to stay up for longer than 1/2 a second. Can anyone help please? thanks
I assume you are doing a console program? If so stick a while loop at the end of the program that only breaks when the user enters a key.

Ballistic Programs
Advertisement
Try

char dummy;
cin >> dummy;

or

getch();
---visit #directxdev on afternet <- not just for directx, despite the name
Usually i do this right before the "return 0": system("pause");


------------------------------
BASIC programmers don''t die, they just GOSUB and don''t return.
------------------------------BASIC programmers don't die, they just GOSUB and don't return.
alright....well i know how to use two operating systems, windows and linux.
I am guessing you are using windows, but I will tell you how do it on Linux next.

1) Go into MS-DOS
2) type CD \
3) type CD directory
for example, to get to C:\sierra\Half-Life, type CD \sierra\Half-Life
4) Then, just type the name of the program, you dont need to add the .exe to the name of the file if you dont want to.


In Linux:
1) Go into Konsole
2) Like in MS-DOS, use cd \directory
3) Instead of typing the name of the program, you would probably have to type ./ or \. or something (i cant exactly remember, I havent been on linux for about a week, i always get mixed up for some reason) and after the ./ thing type the name of the program (i think you might need a space after the ./ but im not sure)
-oompa loomparea51
quote: Original post by anarchyhl
1) Go into Konsole

Or XTerm, ETerm, ATerm, Gnome Terminal, or whatever .
quote: Original post by anarchyhl
3) Instead of typing the name of the program, you would probably have to type ./ or \. or something (i cant exactly remember, I havent been on linux for about a week, i always get mixed up for some reason) and after the ./ thing type the name of the program (i think you might need a space after the ./ but im not sure)

Well, you could add ''.'' (current directory) to your PATH (environment variable), and then you wont have to add the ''./'' unless the ''.'' is in your PATH after the path of something with the same name. I remember that it ''./'' because unixes use ''/'' for directory seperation, and I remember that because the other slash ''\'' is the ''precedes a literal character'' slash (besides that, it''s a habit now ). There''s no space after the ''./'' since the command line would think it''s a seperate ''word'' and try to execute ''./'' by itself.

Advertisement
Thanks for the replies guys, i have it working now.
this is my thing:

        #include <stdlib.h>int main(){....//somestuff/*#1:*/ system("pause"); //you'll get text though.../*#2:*/ Sleep(3000);     //every thousand is a second.../*#3:*/ getch();         //you shouldnt use using namespace std;/*#4:  use MSVC++ , this compiler is the best! */return 0;}        



[edited by - Pipo declown on June 1, 2002 11:54:04 AM]

This topic is closed to new replies.

Advertisement