You are here:

C/Visual C++ and Excutable files

Advertisement


Question
I previousley has asked the following question:

I created a C file and combile it and link it.

Now when I want to run it (i.e, execute it ) from dos window or using run from the MS C++ window the output flash only once then the "dos" window close. I can put a "scanf" command at the end of the C programme which will hold the DOS window which containe the results. However I am sure there must another way.

I got the following answer:

Instead you can use getch(), which will go away when you hit ENTER (With scanf() you will have to type a character and then hit ENTER).

MY QUESTION IS HOW  CAN THE DOS WINDOW STAY OPEN WERE THE OUTPUT IS PRINTED ON THE DOS WINDOW SIMILAR TO UNIX OR LINUX WINDOW. WITHOUT PUTTING EXTRA COMMANDS LIKE scanf() or getch().

Answer
In Unix or Linux, you will execute the program at command prompt.
So, if you do the same in DOS or Windows, you can observer the same behaviout.
So, open the command prompt by typing "cmd" or "Command" in the Run option of Start Menu.
Goto the place where your program is stored and execute the exe.

-ssnkumar

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.