I am just learning c. I am using compiler of Dev-c++. When I run the program below it just appear for few milliseconds.
#include%26lt;stdio.h%26gt;
main()
{
printf("good");
}
Please suggest I am not able to viev my c program after compileing sucessfully?
You are running the program in the command prompt window?
The output is being printed; however, the program closes as soon as the code completes execution. This all happens very fast.
Prevent the program from closing. Include a statement that forces the program to wait for input from you before it closes.
This next line prevents the program from closing until the user hits a key, any key:
c=getchar();
__________________
EXAMPLE
__________________
#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
char c[1];
//while (toupper (c) == 'Y')
while (c=='Y'|| c== 'y')
{
/* your code here*/
printf("good");
printf("\n Do you wish to continue(Y/N): ");
//scanf("%s", %c);
c=getchar();
}
//This next statement also prevents program from exiting
// until the user hits a key.
getch();
}
Reply:Can you explain a bit more ... What is problem.. Just make it like this %26amp; compile.
#include%26lt;stdio.h%26gt;
main()
{
printf("good\n");
}
flowers gifts
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment