zoukankan      html  css  js  c++  java
  • 实验一、命令解释程序的编写实验

    实验一、命令解释程序的编写实验

     

    网络工程 黄翠连 37
    一、 实验目的
    (1)掌握命令解释程序的原理;
    (2)掌握简单的DOS调用方法;
    (3)掌握C语言编程初步。
    二、实验方法、步骤及结果测试

    #include<stdio.h>
    #include<string.h>
    void main() /*主函数*/
    {
    char *b[11]={"dir","cd","md","rd","cls","date","time","ren","copy","help", "quit"}; /*指针数组存储关键字*/
    int pan(char ch1[],char *j[11]);
    char a[10],*p=a;
    printf("Welcome.........\nPleas enter a command!\nEnter 'quit' to quit.\nFor help,Enter 'help'.\n");
    c1: printf("c:\>");
    scanf("%s",a);
    pan(p,b); /*函数调用*/
    if(strcmp(a,b[10])!=0) /*比较输入的字符串是否quit结束命令*/ goto c1;
    else printf("out of work!!\n");
    }
    int pan(char ch1[],char *j[11]) /*子函数*/
    {
    int i;
    for( i=0;i<11;i++)
    if(strcmp(ch1,j[i])==0) /*比较输入的字符串与数组的关键字是否相等*/
    {
    switch(i)
    {
    case 0:printf("command name is dir.\nIt's function is list file.\nIt's an internal command.\nVolume in drive K gas no label.\nVolume Serial Number is 60F0-6C24\n\n");break;
    case 1:printf("command name is cd.\nIt's function is change directory.\nIt's an internal command.\n");
        break;
    case 2:printf("command name is md.\nIt's function is creat a new directory.\nIt's an internal command.\n");
        break;
    case 3:printf("command name is rd.\nIt's function is delete a directory which is empty.\nIt's an internal command.\n");
        break;
    case 4:printf("command name is cls.\nIt's function is clean screen\nIt's an internal command.\n");
        break;
    case 5:printf("command name is date.\nIt's function is show date.\nIt's an internal command.\n");
        break;
    case 6:printf("command name is time.\nIt's function is shio time.\nIt's an internal command.\n");
        break;
    case 7:printf("command name is ren.\nIt's function is rename a file.\nIt's an internal command.\n");
        break;
    case 8:printf("command name is copy.\nIt's function is copy files.\nIt's an internal command.\n");
        break;
    case 9:printf("dir\tcd\tmd\trd\tcls\ndate\ttime\tren\tcopy\nEnter \" quit\" to quit this program!!\n");
        break;
    case 10:printf("Thanks for using it,bye!!\n");
        break;
    }
    return 1;
    }
    printf("No this one!!\nNot a internal commal.\n");
    return 0;
    }

     三、实验结果


    四、 实验总结

    心得体会,实验过程的难点问题及其解决的方法。

    不算难

  • 相关阅读:
    全国省市县三级数据库
    多源教学数据管理系统之团队课设博客
    1.判断字符串中的字符是否Unique
    [转载]linux防火墙基础和管理设置iptables规则
    (转)Sed使用详解
    2.判断回文(Anagrams)
    【转载】关于23 种设计模式的有趣见解
    macbook M1芯片在centos8下安装k8s笔记
    Winform 学习初级 从WebForm到WinForm
    如何建立数据模型
  • 原文地址:https://www.cnblogs.com/123hcl/p/4408782.html
Copyright © 2011-2022 走看看