Once can test the code in DOS too?

In summary, during a conversation about testing code, it was mentioned that you can run a console application in a command prompt window even without a compiler. This is done by navigating to the directory where the executable is located and running it. The speaker also mentioned that Visual Studio has a source level debugger for testing code, and that there are free versions such as the 2010 version. Additionally, it was suggested to change the default directory of the DOS window to make it easier to access the executable.
  • #1
PainterGuy
940
69
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
  • #2
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.
 
  • #3
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
 
  • #4
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.
 
  • #5
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.
 
  • #6
everyone many thanks to you all. this helped me. much grateful.

cheers
 
  • #7
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.
 
  • #8
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
 
  • #9
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 \.
 

Related to Once can test the code in DOS too?

1. How do I test code in DOS?

To test code in DOS, you will need to open the Command Prompt and navigate to the directory where the code is located. Then, type in the name of the code file and press enter to run it.

2. Can any type of code be tested in DOS?

Yes, DOS can be used to test various types of code, including batch files, C++, and Java. However, some advanced features may not be available in DOS, so it may not be suitable for testing all types of code.

3. What advantages does testing code in DOS have?

Testing code in DOS can be useful because it allows for quick and simple testing without the need for a complex development environment. It can also be helpful for troubleshooting and debugging code.

4. Are there any limitations to testing code in DOS?

While DOS can be a useful tool for testing code, it does have some limitations. For example, it may not have access to certain libraries or resources that are available in a full development environment. Additionally, it may not support all the features of modern programming languages.

5. Can code be tested in DOS on modern computers?

Yes, it is possible to test code in DOS on modern computers. However, since DOS is an older operating system, it may not be compatible with newer hardware and may require emulation or virtualization software to run on modern computers.

Similar threads

  • Programming and Computer Science
Replies
4
Views
2K
Replies
6
Views
1K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
24
Views
3K
  • STEM Academic Advising
Replies
11
Views
1K
Replies
4
Views
4K
  • Computing and Technology
2
Replies
44
Views
3K
  • Programming and Computer Science
Replies
6
Views
3K
Back
Top