Once can test the code in DOS too?

  • Thread starter Thread starter PainterGuy
  • Start date Start date
  • Tags Tags
    Code Dos Test
Click For Summary

Discussion Overview

The discussion revolves around the ability to test and run console applications in a DOS environment, particularly focusing on the use of command prompt for executing compiled code. Participants explore the prerequisites for running code, the distinction between running and testing, and the use of different programming environments.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant expresses confusion about running code in DOS without a compiler, seeking clarification on the process.
  • Another participant explains that a program must be compiled and linked before it can be run in a command prompt, emphasizing that source code cannot be executed directly.
  • A participant inquires about navigating to a specific executable file in DOS and asks for clarification on binary files, noting their experience with downloading programs.
  • Instructions are provided on using DOS commands to change directories and run executables, highlighting the difference between running a program in command prompt versus double-clicking the executable.
  • Discussion includes the mention of using Visual Studio's debugger with console applications for testing purposes, suggesting that other compilers may offer similar functionalities.
  • A participant mentions trying to install Visual Studio but opted for Dev-C++ due to compatibility issues, seeking opinions on its quality.
  • Another participant suggests setting a default directory in the command prompt to streamline navigation.

Areas of Agreement / Disagreement

Participants generally agree on the need to compile code before running it in DOS, but there are varying opinions on the best tools and methods for testing and running applications. The discussion remains unresolved regarding the best choice of IDE or compiler for beginners.

Contextual Notes

Some participants express uncertainty about specific DOS commands and their usage, and there are references to different programming environments that may affect the testing process.

Who May Find This Useful

Individuals interested in learning about running console applications in a command prompt, those exploring different programming environments, and beginners seeking guidance on using DOS commands may find this discussion beneficial.

PainterGuy
Messages
938
Reaction score
73
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 \.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
Replies
6
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 24 ·
Replies
24
Views
4K
  • · Replies 12 ·
Replies
12
Views
3K
Replies
12
Views
2K
Replies
6
Views
4K
Replies
2
Views
2K
Replies
4
Views
5K