Public Group

#### Archived

This topic is now archived and is closed to further replies.

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

This topic is 5890 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

##### Share on other sites
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

Try

char dummy;
cin >> dummy;

or

getch();

##### Share on other sites
Usually i do this right before the "return 0": system("pause");

------------------------------
BASIC programmers don''t die, they just GOSUB and don''t return.

##### Share on other sites
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)

##### Share on other sites
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.

##### Share on other sites
Thanks for the replies guys, i have it working now.

##### Share on other sites
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]

1. 1
Rutin
24
2. 2
3. 3
JoeJ
18
4. 4
5. 5

• 13
• 38
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631714
• Total Posts
3001861
×