Examples do not get much more simple than this!

#include <iostream>
 
using namespace std;
 
int main ()
{
  cout << "Hello World!" << endl;
  return 0;
}

return(0) means “I am done, good-bye” this means that the program will run and immediately disappear. From Visual studio we may want to see what it did before it goes away so instead of “returning” to what we were doing before, we will ask the system to wait by using“

  system("pause");

In addition to:

  return 0;

So the improved version looks like:

#include <iostream>
 
using namespace std;
 
int main ()
{
  cout << "Hello World!" << endl;
  system("pause");
  return 0;
}
cs-142/hello.txt · Last modified: 2014/09/09 16:16 by kseppi
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0