I use a printf function to print output and scanf to read the input.
Here is a sample of what the code looks like in practice
void main()
{
int no;
printf("Enter a number: ");
scanf("%d", &no);
printf("\nHere is your number: %d", no);
}
OK, the issue is once I compile and run the environment closes the DOS window immediately after it reads input with scanf. For no apparent reason it will not allow that last printf statement.
Just to make sure if I wrote the program properply I ran the executable outside DEVC++ and everything worked fine.
Please help!!!!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
> For no apparent reason it will not
> allow that last printf statement.
It is normal behaviour for a GUI OS to close an applications window as soon as the program terminates. That is all that happened, your program terminated.
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My problem is when I run a simple C program.
I use a printf function to print output and scanf to read the input.
Here is a sample of what the code looks like in practice
void main()
{
int no;
printf("Enter a number: ");
scanf("%d", &no);
printf("\nHere is your number: %d", no);
}
OK, the issue is once I compile and run the environment closes the DOS window immediately after it reads input with scanf. For no apparent reason it will not allow that last printf statement.
Just to make sure if I wrote the program properply I ran the executable outside DEVC++ and everything worked fine.
Please help!!!!
> For no apparent reason it will not
> allow that last printf statement.
It is normal behaviour for a GUI OS to close an applications window as soon as the program terminates. That is all that happened, your program terminated.
Clifford
Please look at the thread in this very forum with the title
"Please Read Before Posting a Question"
Your question is answered there.
Wayne