Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
How can we print the output of the program(which is in the black environment, dos form)in the c++ visual studio 6 compiler?

When you create the project, select "Console Program" or something like that. Then when you run the program, the output will be in a DOS-type window.
But, once the program ends, the DOS-type window closes. So, you'll want to add something at the end of the program to cause the program to stop, and not end right away.
Most people add some type of char input statement to cause the program to wait for a character input before ending. Something like:ch = getchar();
If you have a non-console project, I don't know if there is a way to get output to a console window.

Most programmers prefer not to make system() calls (which would make Don's method the preferred one).
AKhalifman@hotmail.com

Perhaps, back in the day when memory was expensive and hard drives were the size of our floppy disks... I could see a justified reason not to make system calls.
With today's technology, I do not see a reason to rule out a system call. It is strictly up to the programmer at what comes to mind first. Both methods work fine... its good to be flexible and to have alternatives.

I'd imagine it would have something to do with getting into the habit of making code easily transferrable to other Operating Systems (system() is OS specific, whereas getch() is not)
Not to say that all of us are going to transfer ALL of our code to Linux someday, but it doesn't hurt to get into these habits early (I always thought that I'd *never* need to program for Linux...yet, here I am, learning Linux programming in order to write and/or help write a module of Half-Life ^_^)AKhalifman@hotmail.com

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |