Skip to content
View in the app

A better way to browse. Learn more.

Tip.It Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Just started learning C++

Featured Replies

Today I mustered the will to bust out my Sams teach yourself C++ book, lets just say I've had less frustrating experiences. After all kinds of wonderful issues due to the C++ compiler (Borland: C++BuilderX) not installing correctly on my computer, I finally got a trial version of the 2009 compiler and dove into the infamous "Hello World!" program.

 

 

 

When I compile/link/run this code, the command prompt shows up for a split second then disappears. No errors are found and everything seems to be working correctly. I suspect my problem lies within the act of compiling -> link -> run, but I feel like I'm doing everything correctly. If someone could point out some possible mistakes or has some advice I would appreciate it. Below is the code I used.

 

 

 


#include 



int main()

{

std::cout << "Hello World!\n";

return 0;

}

yuki2d.png

To compile your program with debug information, choose Project|Options, click the

 

Compiler page, and make sure Debug information is checked.

 

 

 

Pulled it from the C++ Builder 6 Quick Start guide on this page: http://docs.embarcadero.com/products/rad_studio/

 

 

 

Just for the record, it compiles and runs without errors on g++. Good luck with C++ man. :P

Linux User/Enthusiast Full-Stack Software Engineer | Stack Overflow Member | GIMP User
s1L0U.jpg
...Alright, the Elf City update lured me back to RS over a year ago.

It's working fine. It quits because it ends outputting hello world and there's to interrupt.

 

 

 

This is how you need to do it (snippet from my program)

 


int check()

{

   if( Process( ), Modules( ), Users( ), Registry( ) == 0 )

   {

       printf( "Nothing Detected\n" );

       getchar( ); // - This will pause the program until you press any key.

       ExitProcess(0);

       return 0;             

   }



 

 

 

By the way I use Dev-C++, I recommend you do the same.

DevCpp looks good yeah, as it supports GCC based compilers like MinGW (From what I understand you're on Windows).

C2b6gs7.png

The reason is simple, you didn't ask the system to pause, so it continues and stops the program after showing the Hello World.

 

 

 

The way I did it when I started programming is as follows.

 

 

 

#include 

#include 



using namespace std;



int main ()

{

cout << "Hello World" << endl;



_getch();



return 0;

}

 

 

 

But On windows you have this too:

 

 

 

#include 



using namespace std;



int main ()

{

cout << "Hello World" << endl;



system("pause");



return 0;

}

 

 

 

LOL all that just to tell you it's a simple need to stop the program from closing (return 0 tells the execution is finished, in this case, and that's why the program closes right away if you don't put something before that).

From what I've heard using

 

 

 

system("pause");

 

 

 

is generally "bad", due to it calling a windows function. It is better to wait for userinput or likewise.

20477083.gif

[Whip drops: 13]

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.