Command interpreter experiment

Source: Internet
Author: User

I. Purpose and Requirements

1. Purpose of the experiment

(1) Master the Principle of command interpretation procedure;

(2) Master the simple Dos call method;

(3) 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 task assigned by the teacher, the design, coding and testing work is done.

three . 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 () {CharCMD [ -][ -]={"dir","CD","MD","Rd","Date"," Time","CLS","Ren",        "Copy"," Help","quit"}; Charstr[ -];  while(1) {printf ("Enter a display character");        Gets (str); if(strcmp (str,cmd[0])==0) {printf ("dir indicates no parameters: View the File box folder for the current directory \ n"); }        Else if(strcmp (str,cmd[1])==0) {printf ("CD Directory Name: Enter a specific folder. \ n"); }        Else if(strcmp (str,cmd[2])==0) {printf ("MD Directory Name: Create a specific folder. \ n"); }        Else if(strcmp (str,cmd[3])==0) {printf ("Rd Directory Name: Deletes a specific folder. \ n"); }        Else if(strcmp (str,cmd[4])==0) {printf ("CLS Directory Name: Indicates the clear screen function. \ n"); }             Else if(strcmp (str,cmd[5])==0) {printf ("Data Directory Name: set date. \ n"); }             Else if(strcmp (str,cmd[6])==0) {printf ("Time Directory Name: Set the times. \ n"); }             Else if(strcmp (str,cmd[7])==0) {printf ("ren directory name: Indicates that the file was changed to a name. \ n"); }             Else if(strcmp (str,cmd[8])==0) {printf ("Copy directory Name: Represents the Copy command. \ n"); }             Else if(strcmp (str,cmd[9])==0) {printf ("CD Directory Name: Enter a specific directory. \ n"); printf ("MD Directory Name: Create a specific directory. \ n"); printf ("dir indicates no parameters: View the File box folder for the current directory \ n"); printf ("Rd Directory Name: Deletes a specific folder. \ n"); printf ("CLS Directory Name: Indicates the clear screen function. \ n"); printf ("Data Directory Name: set date. \ n"); printf ("Time Directory Name: Set the times. \ n"); printf ("ren directory name: Indicates that the file was changed to a name. \ n"); printf ("Copy directory Name: Represents the Copy command. \ n"); }             Else if(strcmp (str,cmd[Ten])==0)         {             return; }         Else{printf ("you entered the wrong information, please re-enter \ n"); }    }}

Five Run results

Vi. Summary

This experiment is not difficult according to reason, but start writing, what all forget, freshman learned basically forget the light, so in writing procedures need to ask degrees Niang. Just like some identifiers forget the meaning, there are some normative errors in writing and so on.

Command interpreter experiment

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.