Once can test the code in DOS too?

  • Thread starter Thread starter PainterGuy
  • Start date Start date
  • Tags Tags
    Code Dos Test
AI Thread Summary
The discussion revolves around running console applications in a command prompt (DOS) environment. Users clarify that while source code cannot be executed directly, once a program is compiled and linked into an executable file (e.g., abc.exe), it can be run from the command prompt. To navigate to the executable, users can utilize basic DOS commands like "cd" to change directories. Executable files, including .exe files, are binary files, which are distinct from other file types. Additionally, users discuss the option of using Visual Studio's debugger for testing code and mention alternatives like Dev-C++ for those unable to install Visual Studio. The conversation also touches on setting a default directory for easier access to executables.
PainterGuy
Messages
938
Reaction score
72
hello nice people,

some guy was saying something that one can check his code in dos also. the instructor said yes. i didnt understand it. it will mean that you can test the code even without compiler. i didnt understand the whole story so i hope you can fill in the gaps. any ideas what they were saying. much thankful for your generous help.

cheers
 
Technology news on Phys.org
If your program is a console application, then yes, you can run it in a command prompt window, but you need to have compiled and linked it first. You can't run your source code (e.g., myprogram.c or myprogram.cpp) directly.

After you have "built" your application (compiled and linked it), open a command prompt window (aka DOS window) and navigate to the directory that contains your executable. Then type the name of the executable.

This isn't "testing" your code - it's running it. When you run your code in Visual Studio, another application, vshost.exe, is running, and it allows you to single-step through your code, view variables, memory, the stack, and a lot of other things.
 
much thanks Mark44.

now i know what it is. my first line at command prompt dos reads: c:\documents and settings\administrator>. assume i have console program named abc.exe in my documents folder and using pc as administrator. then how do reach to this abc.exe in dos. actually as far as i remember i nver used dos in past. so show me the way.

many times when me downloads some program it tells its a bin file. what this bin file? are not every exe file in binary? i appreciate your kind help.

cheers
 
http://www.computerhope.com/overview.htm

There's some basic DOS commands.

Essentially, to get to your program, you will use the cd command (change directory), and cd .. (go up one directory).

To get to your documents folder it might be something like this:
cd ..
cd Documents

Then to run the program just type in abc.exe and it will run. You can also run the program by double clicking on the exe, that should start it in the command line, but this way is not very good as the program will run and exit the window as soon as it's done running, and typically you want to be able to look at the output for an appreciable length of time.
 
You can either specify the full path of the executable, or you can use chdir to change directory to the dir where your exe is.

Executable files are binary files, as are zip archives and similar, as well as many other file types.
 
everyone many thanks to you all. this helped me. much grateful.

cheers
 
If you're using visual studio (express versions are free), you can run it's source level debugger with a dos console program, which would allow you to "test" the code. Other C / C++ compilers may offer the same option.
 
thanks rcgldr. yes me have told express versions are free. me tried to install 2010 version but it needed xp sp3. so me was in hurry download dev-c++ which is free to. u think its good? your opinion is aprreciated.

cheers
 
If you get tired of changing directories, you can also set the default directory to something else. Right click on your shortcut to the DOS window, select Properties and change the Start In directory on the Shortcut tab. You can start in the C:\ directory by just putting a \.
 
Back
Top