Programming of a DOS command interpreter

Source: Internet
Author: User

I. Purpose and REQUIREMENTS

1. Purpose of the experiment

(1) Recognize DOS;

(2) Master the Principle of command interpretation procedure;

(3) Master the Simple Dos call method;

(4) Master C language programming preliminary.

2. Experimental requirements

Write a command-line interpreter similar to Dos,unix

(1) Self-defined system prompt

(2) Custom set of commands (8-10)

(3) User input Help to find commands

(4) List the function of the command, distinguish internal or external commands

(5) User input quit quit

(6) Internal commands are dir, CD, Md,rd, CLS, date, time, Ren, copy, etc.

Ii. contents of the experiment

According to the requirements, complete the design, coding, testing work.

Third, the experimental environment

1. PC Microcomputer

2. Windows Operating System

3. A/C + + program Development Integration Environment

Four, the experimental principle and the core algorithm reference program segment

#include <stdio.h>
#include <string.h>
Main ()
{
Char cmd[20][20]={"dir", "CD", "MD", "RD", "CLS", "Date", "Time", "Ren", "Copy", "Help", "quit"};
Char str[20];
while (1)
{
printf ("Please enter the indicator");
Gets (str);
if (strcmp (str,cmd[0]) ==0)
{
printf ("dir means no parameters: View the text and folder of the current directory \ n");
}
else if (strcmp (str,cmd[1]) ==0)
{
printf ("CD directory name: Enter a specific directory \ n");
}
else if (strcmp (str,cmd[2]) ==0)
{
printf ("MD Directory name: Establish a specific folder, DOS under the habit called Directory, win under the habit of calling folder \ n");
}
else if (strcmp (str,cmd[3]) ==0)
{
printf ("Rd Directory name: delete a specific folder \ n");
}
else if (strcmp (str,cmd[4]) ==0)
{
printf ("CLS clears screen \ n");
}
else if (strcmp (str,cmd[5]) ==0)
{
printf ("Data set date command, function is set date \ n");
}
else if (strcmp (str,cmd[6]) ==0)
{
printf ("Time system clock Settings command, function: Set or display system period. \ n");
}
else if (strcmp (str,cmd[7]) ==0)
{
printf ("Ren" means that the file changed to a name, the format of the Ren command is: The file name of the ren source filename \ n ");
}
else if (strcmp (str,cmd[8]) ==0)
{
printf ("Copy means copy command, copy a file to another place \ n");
}
else if (strcmp (str,cmd[9]) ==0)
{
printf ("dir means no parameters: View the text and folder of the current directory \ n");

printf ("CD directory name: Enter a specific directory \ n");

printf ("MD Directory name: Establish a specific folder, DOS under the habit called Directory, win under the habit of calling folder \ n");

printf ("Rd Directory name: delete a specific folder \ n");

printf ("CLS clears screen \ n");

printf ("Data set date command, function is set date \ n");

printf ("Time system clock Settings command, function: Set or display system period. \ n");

printf ("Ren" means that the file changed to a name, the format of the Ren command is: The file name of the ren source filename \ n ");

printf ("Copy means copy command, copy a file to another place \ n");
}
else if (strcmp (str,cmd[10]) ==0)
Return
Else
{
printf ("You enter the wrong information, please re-enter: \ n");
}
}

}

Analysis of experimental results

1. Enter one of the commands

2. Enter Help to display all commands

3. Input error Instructions

4. Enter quit to close the program directly

V. Summary of the Experiment

Through this experiment, is to review a C language, the function is relatively simple, through while loop implementation, but still need to learn more knowledge.

Programming of a DOS command interpreter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.