Okay, I'm going to assume your sample program looked something like this:
[C++]
Code: Select all
#include <iostream>
int main() {
cout << "Hello World";
return 0;
}
To stop it from dieing so fast like that, you would do something like this, and don't worry about what it means for now, your book will explain later.
Code: Select all
#include <iostream>
using namespace std;
int main() {
int dummy_variable;
cout << "Hello World";
cin >> dumby_variable;
return 0;
}
Also, the reason that it doesn't just close out on you at school is because Metroworks Codewarrior does this step for you and Dev-C++/VisualC++ doesn't.
Using C, not C++?
Your code would look like this:
[C]
Code: Select all
#include <stdio.h>
int main(void)
{
printf("Hello World");
return 0;
}
Basically, it won't exit until you push enter.
Code: Select all
#include <stdio.h>
int main(void)
{
int dumby_variable;
printf("Hello World");
scanf("%d", &dumby_variable);
return 0;
}