Public Group

# Command line arguments? DOS?

This topic is 3707 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Well I have been learning C++ for a short while and I am understanding most of what i have learned except for Command line arguments. Both the book I have (C++ without fear) and most online tutorials confuse me on one subject. Are command line arguments important for non DOS operating systems? My book has a very weird explanation and I just want a simple one! Frankly i dont understand a lot about The computer seeing as I am a begginner (newb). It would be nice if someone could help me understand. and i also would like it if someone could point me in the direction of a site that can explain to me what exactly DOS is (besides the gamedev.net game dictionary.) Please dont bash on me because im a begginner. (We all have to start somewhere dont we?) all help is appreciated and thanked for beforehand.

##### Share on other sites
Microsoft DOS is an operating system. It is the operating system that existed before Windows. It is command line driven, which means there was no GUI (graphical user interface). You had to type commands to do stuff. In modern versions of Windows that command line interface is still available (go to: run, type "cmd", hit enter), though it is not usually accessed by average users.

Command line arguments are still important. In windows you can pass command line arguments to an application by right clicking its icon and selecting properties. Within that dialog there is a field where you can specify command line arguments (sorry I can't say specifically where, I'm not on a windows machine right now)

Unix based operating systems like Linux which are still very much command line driven (even though you can optionally have a GUI) have far more use for command line arguments than Windows applications.

##### Share on other sites
DOS is often used (incorrectly) to refer to the Windows command shell/prompt (more generally, this is a type of console). You can see this console by clicking Start->Run->"cmd"->OK. Type 'help' for a list of commands, and 'COMMAND_NAME_HERE /?' to get more detailed information on that command. Type 'exit' to win a unicorn. Or exit. One of the two.

Note: you can also run programs that are located in certain directories (technically, usually the current working directory and anything stored in the PATH environment variable, which you can display using 'echo %PATH'). These programs are run simply by typing their name; their names won't show up when you type 'help', though.

Technically, DOS is a fairly ancient (in a computing context) operating system produced by a number of manufacturers in a number of varieties (e.g. Microsoft had MS-DOS). There are still versions under current development, as it is useful in certain contexts (its crude simplicity makes it a decent 'jumping off point' for operating system development, for example), such as FreeDOS.

Command line arguments are important if you need them - if you mean 'do programs other than console applications use command line arguments?' then the answer is 'yes'.

Go to Start->Run->'notepad test.txt'->OK

Notepad will prompt you as to whether you want to create the file; if test.txt actually exists, then it'll open it for you. This is (roughly) what happens if you double click 'test.txt' or drag 'test.txt' over the notepad executable. Lots of applications work like this under the cover (try Internet Explorer's kiosk mode: 'iexplore -k www.google.com'; alt+F4 to exit).

##### Share on other sites
Command line arguments are not just limited to DOS, they appear in both Linux, MAC and Windows. For example:

int main(int argc, char *argv[]){  // argc is a variable that contains the number of arguments entered into the program  // argv is an array of char arrays, that is the arguments entered}

Much like in Windows you can have the following:

int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){  // lpCmdLine is exactly like the char *argv variable above}

##### Share on other sites
DOS is the acronym for "disk operating system". Bill Gates owes his fortunes to it.

On Windows vestiges remain in the command prompt, aka console window. See Win32 Console and google: console window for greater details. As to what can be done with the console window, see google: batch file.

To launch a command programmatically, the two api functions to check out are ShellExecute and CreateProcess.

Are command line arguments important for non-DOS operating systems? For advanced and expert users the answer is yes. For casual users the answer is no. For programmers familiarity with the command line is recommended. It's essential for getting around on unix based systems.

As a beginner, most of the programs you will learn to program with will likely be intended to run from the command line. Such programs are easier to code as they are simpler (there's not much in the way of interface programming to confuse things).

HHH

##### Share on other sites
Quote:
 Original post by LessBreadHHH

Off topic: What does HHH mean? Hungry, hungry hippos is all I could come up with.

##### Share on other sites
I would like to point out that Most of the newer Microsoft Operating systems do not have dos they have a Win32 Console that you can access its not that same as dos and when programing its a big differnece. When programing with a microsoft compilere you do not get a dos console you can create a project for a win32 console witch is differnt from dos as most things you try to do Dos based with i tlike ploting pixels is not actualy posible. I found with C++ books some of the older ones do not manage to mention such things and if you ever try to plot pixels to a win32 console application id like to know how :p the point being is a win32 console is not really good for graphics its a nice thing you can use from time to time for testing things or doing a text based adventure. There are a few instances where you can use ascii keys and Windows Handels to output and input to do very very basic graphic like things but its is far from being able to display an image.

I am not sure if this really helps but i would just like to recommened that haveing a fiarly up to date C++ book like ( C++ in 21 days With STL ) is a good one as i have read older ones and they don't really show you some o fthe pitfalls of the language as well as they should.

In all reality you may want to read two C++ Books and just see the differnece bettween them as for command line the above explinations are correct so i will not elaborate on it.

but for the most part Dos itself is well kind of out dated but stilll important funny how things hang around..

Hope this helps and don't worrie about command line that much as you probaly won't use it unless your useing an older compiler that does not run in a win32 mode check out Microsoft Visual C++ Express its a free C++ complier from microsoft it is not defaulty setup to do windows but there are instructions on how to do it when you are ready to.

Regards Jouei.

##### Share on other sites
Quote:
Original post by fpsgamer
Quote:
 Original post by LessBreadHHH

Off topic: What does HHH mean? Hungry, hungry hippos is all I could come up with.

LoL Hope that Helps or something like that

##### Share on other sites
well thanks for all the help. I really appreciate it. as to the books im reading i only have one so far (C++ without fear which was published in 2005) and i would like to get another. I am thinking about getting 'Thinking in C++' which i have heard good things about. Oh and sorry about all the 'i's. If there are any other books that you recomend besides 'Accelerated c++' which i am looking into i would like to hear about them. I hear that you can get thinking in c++ for free. Is that true?

Thanks again

[Edited by - steveworks on May 24, 2008 9:02:39 AM]

1. 1
Rutin
24
2. 2
JoeJ
20
3. 3
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002046
×