Command Line Interpreter...

Command Line Interpreter

Definition: A command line interpreter is any program that allows the entering ofcommands and then executes those commands to the operating system.
In most Windows operating systems, the primary command line interpreter is Command Prompt. Windows PowerShell is a more advanced command line interpreter available alongside Command Prompt in more recent versions of Windows.
In Windows XP and Windows 2000, a special diagnostic tool called Recovery Consolealso acts as a command line interpreter to perform various troubleshooting and system repair tasks.
Any command line interpreter program is also often referred to in general as a command line interface.
 

List of Command Prompt Commands

The Command Prompt in Windows provides access to over 280 commands! These commands are used to do certain operating system tasks from a command line interfaceinstead of the graphical Windows interface we use most of the time.

Launch Paint from command line


We can launch MS Paint application from command prompt also. Just run the command mspaint and it will open paint application.
c:> mspaint
snapshot of Paint application in Windows Vista


What is a Command?

A command is a specific instruction given to a computer application to perform some kind of task or function.
In Windows, commands are usually entered via a command line interpreter like Command Prompt or Recovery Console.
Important: Commands must always be entered into a command line interpreter exactly. Entering a command incorrectly (wrong syntax, misspelling, etc.) could cause the command to fail or worse, could execute the wrong command or the right command in the wrong way, creating serious problems.
There are many different "kinds" of commands, and many phrases that use the wordcommand that probably shouldn't because they're not actually commands. Yes, it's kind of confusing.
Below are some popular kinds of commands you might encounter:

Command Prompt Commands

Command Prompt commands are true commands. By "true commands" I mean that they are programs that are intended to be run from a command line interface (in this case the Windows Command Prompt) and whose action or result is also produced in the command line interface.
See my List of Command Prompt Commands for a complete list of these commands with all the details you'd ever want or check out my one-page table of the same without the explanations of each command.

DOS Commands

DOS commands, more correctly called MS-DOS commands, might be considered the "purest" of the Microsoft based commands since MS-DOS had no graphical interface so each command lives completely in the command line world.
Don't confuse DOS commands and Command Prompt commands. MS-DOS and the Command Prompt may appear similar but MS-DOS is a true operating system while Command Prompt is a program that runs within the Windows operating system. Both share many commands but they are certainly not the same.
See my List of DOS Commands if you're interested in the commands that were available in the latest version of Microsoft's DOS operating system, MS-DOS 6.22.

Run Commands

A run command is simply the name given to an executable for a particular Windows-based program.
A run command is not a command in the strictest sense - it's more like a shortcut. In fact, the shortcuts that live in your Start Menu or on your Start Screen are usually nothing more than an icon representation of the executable for the program - basically a run command with a picture.
For example, the run command for Paint, the painting and drawing program in Windows, is mspaint and can be run from the Run box or Search box, or even from the Command Prompt, but Paint is obviously not a command line program.
Some other examples are bit more confusing. The run command for Remote Desktop Connection, for example, is mstsc but this run command does have some command line switches that make opening the program with specific parameters very easy. However, Remote Desktop Connection is not a program designed for the command-line so it's not really a command.
See my Run Commands in Windows 8 or Run Commands in Windows 7 article for a list of program executables in your version of Windows.

Control Panel Commands

Another command you'll see referenced that isn't really a command is the Control Panel applet command. A Control Panel applet command is really just the run command for theControl Panel (control) with a parameter instructing Windows to open a specific Control Panel applet.
For example, executing control /name Microsoft.DateAndTime opens the Date and Time applet in Control Panel directly. Yes, you can execute this "command" from the Command Prompt, but the Control Panel is not a command line program.
See my Command Line Commands for Control Panel Applets for a complete list of these "commands."

Recovery Console Commands

Recovery Console commands are also true commands. Recovery Console commands are only available from within the Recovery Console, the command line interpreter available only for troubleshooting problems and only in Windows XP and Windows 2000.
I also keep a list of Recovery Console commands with details and examples for each command.



How to Open a Terminal Session in Windows 7

How to Open a Terminal Session in Windows 7

How to Open a Terminal Session in Windows


The Command Prompt represents Windows 7's equivalent to Mac's Terminal. This text-only application abandons Windows' familiar graphical user interface and allows technicians to issue textual commands. While some users dislike this interface, it may be just the tool you need to perform tasks on your business computer. Windows offers numerous ways to open a session in Command Prompt depending on your current needs.
Step 1
Press "Win-R," type "cmd" and press "Enter" to open a Command Prompt session using just your keyboard.
Step 2
Click the "Start | Program Files | Accessories | Command Prompt" to open a Command Prompt session using just your mouse.
Step 3
Click the "Start" button and type "cmd." Right-click "Cmd," select "Run as Administrator" and click "Yes" to open Command Prompt with elevated privileges.
Step 4
Hold the "Shift" key, right-click a folder in Windows Explorer and select "Open Command Window Here" to open the Command Prompt at the selected folder's hard drive location.

What is A header file ???

What is A header file ???


                          A header file is a file with extension .h which contains C function declarations and macro definitions and to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that come with your compiler.
You request the use of a header file in your program by including it, with the C preprocessing directive#include like you have seen inclusion of stdio.h header file, which comes along with your compiler.
Including a header file is equal to copying the content of the header file but we do not do it because it will be very much error-prone and it is not a good idea to copy the content of header file in the source files, specially if we have multiple source file comprising our program.
A simple practice in C or C++ programs is that we keep all the constants, macros, system wide global variables, and function prototypes in header files and include that header file wherever it is required.

Include Syntax

Both user and system header files are included using the preprocessing directive #include. It has following two forms:
#include <file>
This form is used for system header files. It searches for a file named file in a standard list of system directories. You can prepend directories to this list with the -I option while compiling your source code.
#include "file"
This form is used for header files of your own program. It searches for a file named file in the directory containing the current file. You can prepend directories to this list with the -I option while compiling your source code.

Include Operation

The #include directive works by directing the C preprocessor to scan the specified file as input before continuing with the rest of the current source file. The output from the preprocessor contains the output already generated, followed by the output resulting from the included file, followed by the output that comes from the text after the #include directive. For example, if you have a header file header.h as follows:
char *test (void);
and a main program called program.c that uses the header file, like this:
int x;
#include "header.h"

int main (void)
{
   puts (test ());
}
the compiler will see the same token stream as it would if program.c read
int x;
char *test (void);

int main (void)
{
   puts (test ());
}

Once-Only Headers

If a header file happens to be included twice, the compiler will process its contents twice and will result an error. The standard way to prevent this is to enclose the entire real contents of the file in a conditional, like this:
#ifndef HEADER_FILE
#define HEADER_FILE

the entire header file file

#endif
This construct is commonly known as a wrapper #ifndef. When the header is included again, the conditional will be false, because HEADER_FILE is defined. The preprocessor will skip over the entire contents of the file, and the compiler will not see it twice.

Computed Includes

Sometimes it is necessary to select one of several different header files to be included into your program. They might specify configuration parameters to be used on different sorts of operating systems, for instance. You could do this with a series of conditionals as follows:
#if SYSTEM_1
   # include "system_1.h"
#elif SYSTEM_2
   # include "system_2.h"
#elif SYSTEM_3
   ...
#endif
But as it grows, it becomes tedious, instead the preprocessor offers the ability to use a macro for the header name. This is called a computed include. Instead of writing a header name as the direct argument of #include, you simply put a macro name there instead:
 #define SYSTEM_H "system_1.h"
 ...
 #include SYSTEM_H
SYSTEM_H will be expanded, and the preprocessor will look for system_1.h as if the #include had been written that way originally. SYSTEM_H could be defined by your Makefile with a -D option.

why and when we use #include?

why and when we use #include?

#include is used to add code into your file during compiling.

So, for example, in order to use a function you muse first declare it (tell the compiler that it exists and what arguments it takes). There are a ton of libraries out there with pre-compiled code. In order to use any of them, you need to '#include' a header file with those function declarations in them.

So, if you have a set of functions/classes that you have written that you think may be nice to have as a library, you can move all the function/class declareations into a header file or files and then you can include them in other code.

the #include directive lets you include code into your code when you compile. So long as the contents of the file fit syntactically with the program you can use it to include any file.

For example often it is nice to have someone with a better grasp of the language to do your text for you. So you can have them put all of their text into a text file (with quotes at the beginning and end of each line). like so:
1"\tThis is some text that is maintained by "
2"some artsy type english majors who do "
3"not know how to code at all, but who "
4"can spell and know grammar. \n"
sometext.txt

then you can include this into your code like so:
01#include <iostream>
02 
03char text[] =
04#include "sometext.txt"
05;
06 
07int main(void) {
08    std::cout << text << std::endl;
09    return 0;
10}


Now I don't recommend doing things this way. I mean that author could insert code into your program (insert all kinds of things -- most of them probably bugs). My point was that so long as the contents of the file fit the syntax of the program you can include anything you would like.

Generally, this is used to include logical units such as library function declarations and classes. Sometimes it is used to include code snippets. Sometimes it is used to include data.