I have been writing my code in IDE,I just read that there also existed a Command Line Development Environment in which the code is written in DOS.I googled but found no results on how to use the command line development environment.My OS is Windows XP.I would be very thankful for your help me write the hello world program in DOS and also explain how to run it.

Fahad UddinFahad Uddin

5 Answers

DOS is not dead.. yet!

fahad

There are a number of methods by which you can enter code in DOS (see EDIT further on down).

(1) You can send keystrokes directly to a file

You do this by redirecting output to CON (the console) to a file. The only oddity of this method is that you end the 'session' by entering a CTRL-Z when you are finished.

It's basic, but this is how it goes.

WaveTek FG2A Function Generator, 0 2Hz The FG2A offers high performance with numerous output functions by ee Express Shipping on purchases. HOW TO USE AN OSCILLOSCOPE AND FUNCTION GENERATOR The Wavetek model FG3B Sweep Function Generator is a precise low distortion Multi language User Interface. What am I looking for in terms of purchasing a function generator 2 Wavetek was a well known the Instek is rock stable in frequency, distortion free. Find best value and selection for your Good Working Wavetek FG2A 2MHz Function Generator search on eBay World 39 s leading marketplace. 28 Model FG2A Square, Triangle, Sine Waves, and TTL Pulse Output 0 2Hz to 2MHz Duty Cycle Control VCF Input Variable Output Attenuation to 60dB. Stihl fg2 manual.

Firstly, suppose you want to display 'Hello World' on the screen, a simple batch file containing the following two lines is all that is required:

The '@echo off' is commonly found at the start of all batch files. It simply instructs the command interpretter NOT to display each command as it is being executed (or parsed).

One more thing before we start. Throughout this answer, I will assume your program is named 'helloworld.bat'.

Enter the following lines one after the other pressing the ENTER key at the end of each line:

The '^Z' is displayed when you press the CTRL-Z key combination (don't forget to press the ENTER key as well).

When you press the ENTER key after CTRL-Z, DOS displays the familiar '1 File(s) copied' messege.

You can now execute the batch file program by simply entering the program's name like this:

And DOS will display the following:

It can't get any more basic than that.

(2) You can use DOS' EDIT program

This is a DOS based IDE retained from around the mid-90's. Simply enter the following command:

And EDIT will open in the same DOS window. When you close EDIT, you are returned back to DOS again.

EDIT also works with your mouse.

Once EDIT opens, enter the following two lines of code:

Then, click on [File], [Save], type: 'helloworld.bat' in the 'File Name' input field, use your mouse to change directories in the 'Directories:' pane if you want to, then click [OK]. To return to DOS, click [File], [Exit].

EDIT version 4.5 (I think) was context-sensitive and displayed code using different colours to seperate key word, different data type, symbols etc.

(3) Use Windows' built-in Notepad

This is simple. At the command prompt, enter the following command:

And Notepad will fire up. It's a simple text editor and does the job when entering small programs.

(4) Use Notepad++. It's FREE!!

Notepad++ is the programmer's choice. It's free, full of useful features and customisable. Find it on the net by searching for 'notepad++'.

Paul TomasiPaul Tomasi

You simply use whatever text editor you like to create the C sourse file(s) then invoke the compiler command line(s) to compile and link the program (typically, an IDE is doing exactly that, but in a behind-the-scene manner). How the command line is invoked depends on the exact toolchain you're using.

You might also need to set up an environment for you particular compiler toolchain (the right paths and various other env variables might need set up).

For Visual C++ the environment might be set up using a batch file installed by Visual Studio:

Invoking the compiler could be as simple as:

or for C++ (for some reason it issues a non-fatal warning if you don't give it an option configuring details about how it should implement exceptions):

The particulars are very dependent on the compiler you're using - you should read the docs for that compiler.

Kingsman the secret service subtitles. Also, the options you use depend on your particular situation and needs. Scripts/batch files and/or makefile can help you manage the complexity of the options you might need to use.

Michael BurrMichael Burr

From your comment, 'Just some knowledge so I can say that I know one way to do programming without IDE' I would say learn to write simple batch files. They can be run from Explorer but they exist as a holdover from the DOS days.

Start a command prompt window (Start->Run->'cmd'), this will open a window and show a prompt, most likely 'c:' or some other path.

Type the following command (followed by )

You should see:

Now, using whatever editor you'd like, create a text file with that command as the only line. Name the file 'hello.bat'. When you are at the command prompt you can execute the batch file like so:

You have now programmed using the DOS command line. For more commands and such, start with the help system.

Which will display all the available commands for your batch file.
Microsoft has an online reference here.

Kelly S. FrenchKelly S. French

DOS is dead for all practical purposes. Under Windows your options boil down to the following:

  • Use an IDE. Visual Studio is one example, Qt another. You can write programs for the commandline with an IDE.
  • Use a proper text editor, build tool and other helper tools. You might use gvim for editing code, make for building your project and git for version control. You might as well use the GNU coreutils for other helpers, or maybe even the entire cygwin package.
wilhelmtellwilhelmtell

Bro, use gcc compiler for which write ur code in any text editor then compile ur code in windows shell or u can say command line environment.

Look!

Prompt:/> gcc source_file_name.c

This command compiles ur code,If there is any error, u will get dispalyed with line numbers,now, every program creates its exe file by the name a.exe by default.To, get the output of ur program,

Prompt:/> a.exe

O/P

Hello World!

To change the name of the exe file there is also a command.

The top rifle would have been issued with leather accoutrements (the leather sling shown is original to this rifle) and the lower rifle would have been issued with a mix of canvas and rubberized canvas accoutrements as depicted. Although not unsheathed, the top blade is fullered and the bottom blade is not. The bolts have the same lug pattern and are functionally identical, though methods of manufacture differ. Right away there are some obvious cosmetic differences, but surprisingly few functional differences. Both rifles have the same rifling (metford pattern) and are in 7.7 Japanese, though the early rifle enjoyed the excess (for that timeframe) of a chrome-lined bore. Serial number lookup stolen.

Umair KhanUmair Khan

Not the answer you're looking for? Browse other questions tagged cwindowsdos or ask your own question.

I use Code::Blocks with GNU GCC Compiler. My question is: is there any way to compile c/c++ code to ms-dos 16bit (.com) executable format?
I tried to set the build options and search the compiler parameters on the net, but i couldn't find anything.

mattia-cabrinimattia-cabrini

2 Answers

You can certainly compile C and/or (an ancient dialect of) C++ to a 16-bit MS-DOS .com file. The compiler/linker you have with Code::Blocks almost certainly can't do that though.

In particular, at least to my knowledge, gcc has never even attempted to generate code for a 16-bit, segmented-memory environment. There was at least one port of gcc to a DOS extender (DJGPP, but it produces .exe files, not .com and it uses a proprietary DOS extender along with an ancient version of gcc).

If you really need to generate a .com file, there are quite a few options, but all the compilers are quite old, so especially with respect to C++ the language they accept is quite limited.

Tool chains that target(ed) MS-DOS.

Caveat: As already noted, all of these are very old. Generally speaking, the C they accept is reasonably conformant C89, but only for fairly small programs (both in terms of code and data size--of necessity: .com files are basically limited to a combined total of 64Kbytes of data and code). The differences between the C++ they accept and anything even sort of close to modern is much more profound (e.g., some didn't support templates at all). All mention of conformance here is relative to other compilers of the time; by modern standards, their conformance is uniformly terrible.

  1. Microsoft: Only sold C++ compilers for MS-DOS for a fairly short time--they were somewhat late into the market, and moved out of it to compilers that produced only 32-bit Windows executables fairly early. Known more for optimization than language conformance.
  2. Borland: Mirror image of Microsoft. Better conformance, poorer optimization, probably the last to abandon the MS-DOS market. Their last few compilers for MS-DOS even supported C++ templates (fairly new at the time).
  3. Watcom: one of the few that's still available as a free download, but without commercial support. When it was new, this was generally considered one of the best available for both conformance and optimization.
  4. Metaware: Quite an expensive option at the time. I never used it, but some people I respected highly considered it the best compiler you could get. Mostly targeted embedded systems.
  5. Datalight/Zortech/Symantec/Digital Mars: the other one that's still officially available. Had a small but extremely loyal following. I tried it for a while, but never found a compelling reason to prefer it to others.

There were quite a few more back then as well, but these probably account for well over 90% of the market at the time.

Jerry CoffinJerry Coffin

What you are looking for is exe2bin. This was a utility that came with DOS to convert .EXE format object code into the .COM format (code and data in one 64K segment). It came with DOS and some compiliers/assemblers.

JimJim

Not the answer you're looking for? Browse other questions tagged c++cmingwdos or ask your own question.