I have got a problem, i wrote the first program hello world. and it is correct because it open's but the problem is: it open's is ms dos for less than a second. and the second program from the manual on this site is the same problem. so can anybody help me??
Jerome
I am not verry good in English so sorrie for all the mistakes
Hi kitekeeter! This is a problem for a lot of noobies! What happens is when you start a program, it calls the starting function (main()). When it does this it processes what you tell it to process (in your case, you send Hello World to the console). After it's done processing, it ends the function and once the main() function ends, the application itself ends.
In other words, you need to somehow stop the function from ending to fast. A popular way is to place a function that uses an interrupt in the function. A popular choice is the C STD, getchar();
1 2 3 4 5 6 7 8
#include <iostream>
int main(int argc, char ** argv)
{
std::cout << "Hello world! Nice weather, eh?" << std::endl;
std::cout << "Press any key to continue...";
getchar();
}
This is my personal way of doing it. There's a tutorial on this site explaining how and why this works.