C Puase Question
RWB
Icrontian
When you run a program in C such as in Visual Basic, what is the information to input to keep the program active? Such as when you run the program you made and when it runs it runs instantly and then automatically quits out. I need to make it so that it stays up.
Such as in the HELLO WORLD beginners program, what is the command that keeps it up instead of closing instantly?
Isn't it ;PUASE or something?
Such as in the HELLO WORLD beginners program, what is the command that keeps it up instead of closing instantly?
Isn't it ;PUASE or something?
0
Comments
Infinite loop would be the quickest (and dirtiest) way to make it stay up if it's a piddly program like Hello world.
for(;;);
while(1);
take your pick.
#include < time.h >
void pause(unsigned int t)
{
int x = clock();
for (int x = clock(); clock() - x >= t;);
}
Then just use pause(5000); for a pause of ~5 seconds.
To be more accurate you'd need 5 * CLOCKS_PER_SECOND, but it's normally 1000 or thereabouts.
I think that will work. I don't have a compiler on here so don't sue me if I made a boo-boo.
// Woops, had to disables smilies again.
// Blah! I had to edit again because of the < > around time.h
getc();
This will block execution until you hit a key. This usually acts as an adequate pause like function.
Then just press enter to quit.