http://s30.photobucket.com/albums/c3...nt=error-1.jpg please look at that and tell me what you guys think is the problem... the program doesnt stay active it just ends...
Printable View
http://s30.photobucket.com/albums/c3...nt=error-1.jpg please look at that and tell me what you guys think is the problem... the program doesnt stay active it just ends...
So I guess this means the problem has been solved.
Regards,
Paul McKenzie
Which is what it's supposed to do.Quote:
Originally Posted by joerules22
What made you think that the main() function isn't supposed to terminate?
Regards,
Paul McKenzie
no wait!... whenever i compile and run ANYTHING (stuff that isnt supposed to end) it just ends after it displays the text. i mean the window disapears.
the window wont even stick around long enough for me to read it..
what about 10 thousand frames per second? can my monitor display all those frames? pQuote:
Originally Posted by TheCPUWizard
That's why you have to run it from the command line as someone said earlier.
Or, you could add a getch() at the end of main before it returns.
-Andy
It looks like you do not know how C++ programs are supposed to work.Quote:
Originally Posted by joerules22
First, the main() function terminates when it exits. Terminating main() means that the program terminates. Nothing makes a program "run forever", unless you make it run forever by introducing a loop, or some other programming method to keep the program running.
Second, a console window can't just "disappear" if you opened the console window yourself and ran the program you posted.
Why not attach one of these exe files, so as to prove that you are doing something wrong, or post one of these C++ programs that's supposed to "run forever". I bet
1) The program does not close the console window, and
2) The program was not programmed to "run forever" as you claim it's supposed to.
Regards,
Paul McKenzie
not run forever thats not what i mean... once i execute the program the window opens and disapears... and if i run it in comand prompt it will not accept any input from me i guess that was what i was trying to get at. you have to realize this is very very hard to describe...
Quote:
and if i run it in comand prompt it will not accept any input from me
This program does not EXPECT any input.Code:#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Even if english is not your first language, please take the time to re-read what you are posting a few times before hitting submit. :rolleyes:
ok im going to take everything u guys have said hookline and sinker and read a bit more on c++ b4 i come back and drive everyone insane on this subject :) ill try to deal with it.
An excellent idea. After you have given it some though, please come back and let us know how it is going.
Good Luck :wave: :thumb:
just one more thing. I have done this b4 compiling and runing the programs the window stayed up but just recently it have been disapearing.
You can put the following at the end of the main() function. It will
cause the program to wait for the user to hit the enter key
Code:cin.sync(); // add these
cin.ignore(); // two lines
return 0;
you are my new god! :p thank you sooo much! i think i understand now!