• 10.10 dos实验


    一、 实验目的

    (1)认识DOS;

    (2)掌握命令解释程序的原理;

    (3)掌握简单的DOS调用方法;

    (4)掌握C语言编程初步。

    二、 实验内容和要求

    编写类似于DOS,UNIX的命令行解释程序

    (1)自行定义系统提示符

    (2)自定义命令集(8-10个)

    (3)用户输入HELP以查找命令的帮助

    (4)列出命令的功能,区分内部还是外部命令

    (5)用户输入QUIT退出

    (6)内部命令有dir, cd, md,rd, cls, date, time, ren, copy等。

    根据要求,完成设计、编码、测试工作。

    三、 实验方法、步骤及结果测试

    3.主要程序段及其解释:

    #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("欢迎来到dos系统
    ");
    
    printf("quit :退出     help:显示所有功能
    ");
    
    c1: printf("请输入命令:");
    
    scanf("%s",a);
    
    pan(p,b); /*函数调用*/
    
    if(strcmp(a,b[10])!=0) /*比较输入的字符串是否quit结束命令*/ goto c1;
    
    else printf("out of work!!
    ");
    
    }
    
    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.
    It's function is list file.
    It's an internal command.
    Volume in drive K gas no label.
    Volume Serial Number is 60F0-6C24
    
    ");break;
    
    case 1:printf("command name is cd.
    It's function is change directory.
    It's an internal command.
    ");break;
    
    case 2:printf("command name is md.
    It's function is creat a new directory.
    It's an internal command.
    ");break;
    
    case 3:printf("command name is rd.
    It's function is delete a directory which is empty.
    It's an internal command.
    ");break;
    
    case 4:printf("command name is cls.
    It's function is clean screen
    It's an internal command.
    ");break;
    
    case 5:printf("command name is date.
    It's function is show date.
    It's an internal command.
    ");break;
    
    case 6:printf("command name is time.
    It's function is shio time.
    It's an internal command.
    ");break;
    
    case 7:printf("command name is ren.
    It's function is rename a file.
    It's an internal command.
    ");break;
    
    case 8:printf("command name is copy.
    It's function is copy files.
    It's an internal command.
    ");break;
    
    case 9:printf("dir	cd	md	rd	cls
    date	time	ren	copy
    Enter " quit" to quit this program!!
    ");break;
    
    case 10:printf("Thanks for using it,bye!!
    ");break;
    
    }
    
    return 1;}
    
    printf("No this one!!
    Not a internal commal.
    ");return 0;
    
     
    
    }

     四、运行结果截图及分析

           当打开运行界面时,就出现

           欢迎来到dos系统

           quit :退出     help:显示所有功能

           请输入命令:

           然后当你输入各种命令就会出现相应的字符串

           输入help就会出现所有命令

           输入quit就会退出界面。

     四、实验心得

           通过这个简单地编写dos系统的程序,让我更加清楚更更加了解操作系统这门课,虽然程序很简单,功能也很简单,不过对我们来说挺有意义的。最开始学习操作系统这门课的时候,说实在的,对操作系统这个概念很模糊,觉得很抽象。然后后来慢慢学习之后发现挺有趣的,还可以自己编写简单的dos系统,给了我一些信心。

  • 相关阅读:
    使用.NET Core创建Windows服务(二)
    使用.NET Core创建Windows服务(一)
    在.NET Core中使用DispatchProxy“实现”非公开的接口
    ASP.NET Core 3.0中使用动态控制器路由
    从零开始实现ASP.NET Core MVC的插件式开发(五)
    微博大数据即席查询(OLAP)引擎实践
    微博数仓数据延时优化方案
    团队工作建议
    GitBook安装部署实操手册
    Wiki.js安装部署实操手册
  • 原文地址:https://www.cnblogs.com/MyDring/p/4843329.html
Copyright © 2020-2023  润新知