#include ‹stdio.h›
#include ‹stdlib.h›
int main()
{
printf("Pause the program!\n");
system("pause");//Pausing the program
}
but i gona introduce u guys for different ways to pause a program, using getchar(); or scanf(); ( read dis, Things to Avoid in C/C++ -- system("pause") )
1st, we will talk abt using scan();, u juz simply type scanf("%d",&cincai); b4 ur program's exit point : for example;
#include ‹stdio.h›
int main()
{
int num;
printf("Pause the program!\n");
scanf("%d",&num); //Pausing the program
//Exit point/return 0;
}
dis approach can "pause" ur program, but the sad thing is, u hav to declare and assign a new variable (mayb u can assign to old variables when u hv multiple variables), n the executable size will b larger ( c more info on : Things to Avoid in C/C++ -- scanf )
another way is to use getchar(); , dis is much simpler as it doesnt need to assign or declare variables, it is oso "cleaner", and doesnt require extra library like system("pause");
way for doing dis is juz as simply as following:
#include ‹stdio.h›
{
printf("Pause the program!\n");
getchar(); //Pausing the program
}
dats all i hav to say abt dis topic, below is de screenshot where i cant get system("pause") do the job well, as stated in the article Things to Avoid in C/C++ -- system("pause") .
