Programming of a DOS command interpreter

Source: Internet
Author: User
Tags strcmp

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

1. Principle Analysis and flowchart

2. SOURCE program

#include <stdio.h>#include<string.h>Main () {Charcmd[ -][ -]={"dir","CD","MD","Rd","CLS","Date"," Time","Ren","Copy"," Help","quit"}; Charstr[ -];  while(1) {printf ("Please enter a display character");    Gets (str); if(strcmp (str,cmd[0])==0) {printf ("dir: The internal command displays the files and subdirectories in a directory. \ n"); }    Else if(strcmp (str,cmd[1])==0) {printf ("CD: Internal command displays the name of the current directory or changes it. \ n"); }    Else if(strcmp (str,cmd[2])==0) {printf ("MD: Internal command creates a directory. \ n"); }    Else if(strcmp (str,cmd[3])==0) {printf ("Rd: Internal command to delete a directory. \ n"); }    Else if(strcmp (str,cmd[4])==0) {printf ("CLS: Internal command clears the screen. \ n"); }        Else if(strcmp (str,cmd[5])==0) {printf ("data: The internal command displays or sets the date. \ n"); }    Else if(strcmp (str,cmd[6])==0) {printf ("Time: Internal command internal command displays or sets system times ... \ n"); }    Else if(strcmp (str,cmd[7])==0) {printf ("Ren: The internal command renames the file. \ n"); }    Else if(strcmp (str,cmd[8])==0) {printf ("Copy : The internal command copies at least one file to another location. \ n"); }    Else if(strcmp (str,cmd[9])==0) {printf ("type: external command \ n"); printf ("the dir\t internal command displays the files and subdirectories in a directory. \ n"); printf ("the cd\t internal command displays the name of the current directory or changes it. \ n"); printf ("md\t Internal command to create a directory. \ n"); printf ("rd\t Internal command to delete directory: \ n"); printf ("cls\t Internal command clears the screen. \ n"); printf ("date\t The internal command to display or set the date. \ n"); printf ("time\t Internal Command Internal command displays or sets the system time. \ n"); printf ("ren\t Internal command renames the file. \ n"); printf ("the copy\t internal command copies at least one file to another location. \ n"); printf ("the help\t External command provides help information for Windows commands. \ n"); printf ("quit\t external Command exit command interpreter \ n"); printf ("\ n"); printf ("\ n"); }    Else if(strcmp (str,cmd[Ten])==0) {printf ("quit:886\n:"); return; }    Else{printf ("you enter the wrong information, please re-enter: \ n"); }    }}

Experimental results Analysis:

1. Enter help after display:

2. For example, enter Date:

Five: Experimental summary

Through this experiment can review the freshman's C, through the online access and get the help of classmates successfully completed the experimental operation.

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.