Some dummy prompts using atexit() and getchar() C functions program example
Compiler: Visual C++ Express Edition 2005
Compiled on Platform: Windows XP Pro SP2
Header file: Standard
Additional library: none/default
Additional project setting: Set project to be compiled as C
Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)
Other info: none
To do: Some dummy prompts using atexit() and getchar() C functions program example
To show: How to use atexit() and getchar() C functions in C programming
// atexit() and getchar() usage
#include <stdlib.h>
#include <stdio.h>
// function prototypes...
void cleanup1(void);
void cleanup2(void);
void main(void)
{
// function call - atexit() - processes the specified function at exit.
atexit(cleanup2);
// another call
atexit(cleanup1);
// end of main
}
void cleanup1(void)
{
// dummy cleanup.....
printf("\nThis is a demonstration...\n");
printf("cleanup....\n");
printf("You computer is SHUTTING DOWN!!!");
getchar();
}
void cleanup2(void)
{
// another dummy cleanup...
printf("\nAnother cleanup...");
printf("\nWINDOWS 20000 is closing the entire program...");
printf("\nPlease WAIT...");
printf("\nSHUTTING DOWN IN PROGRESS...\n");
getchar();
}
Output example:
This is a demonstration...
cleanup....
You computer is SHUTTING DOWN!!!
Another cleanup...
WINDOWS 20000 is closing the entire program...
Please WAIT...
SHUTTING DOWN IN PROGRESS...
Press any key to continue . . .