码迷,mamicode.com
首页 > 其他好文 > 详细

实验1

时间:2015-06-26 10:51:00      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

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

  1 #include<stdio.h>
  2 #include<string.h>
  3 void main()
  4 {
  5     char cmd[30][30]={"dir","cd","md","rd","cls","date","time","ren","copy","help","quit"};
  6     char str[30];
  7     
  8     while(1)
  9     {
 10         printf("hi,please input the order:");
 11         gets(str);
 12         if(strcmp(str,cmd[0])==0)
 13         {
 14             printf("type:order of inside\n");
 15             printf("check the catalogue");
 16             printf("\n");
 17             printf("\n");
 18             //break;
 19         }
 20 
 21         else if(strcmp(str,cmd[1])==0)
 22         {
 23             printf("type:order of inside\n");
 24             printf("enter the catalogue");
 25             printf("\n");
 26             printf("\n");
 27             //break;
 28         }
 29 
 30         else if(strcmp(str,cmd[2])==0)
 31         {
 32             printf("type:order of inside\n");
 33             printf("make the new catalogue");
 34             printf("\n");
 35             printf("\n");
 36             //break;
 37         } 
 38 
 39 
 40         else if(strcmp(str,cmd[3])==0)
 41         {
 42             printf("type:order of inside\n");
 43             printf("delete the document");
 44             printf("\n");
 45             printf("\n");
 46             //break;
 47         }
 48 
 49         else if(strcmp(str,cmd[4])==0)
 50         {
 51             printf("type:order of inside\n");
 52             printf("clean the screen");
 53             printf("\n");
 54             printf("\n");
 55             //break;
 56         }
 57 
 58         else if(strcmp(str,cmd[5])==0)
 59         {
 60             printf("type:order of inside\n");
 61             printf("show or reset the date");
 62             printf("\n");
 63             printf("\n");
 64             //break;
 65         }
 66 
 67         else if(strcmp(str,cmd[6])==0)
 68         {
 69             printf("type:order of inside\n");
 70             printf("show or reset the time");
 71             printf("\n");
 72             printf("\n");
 73             //break;
 74         }
 75 
 76         else if(strcmp(str,cmd[7])==0)
 77         {
 78             printf("type:order of inside\n");
 79             printf("modify the name");
 80             printf("\n");
 81             printf("\n");
 82             //break;
 83         }
 84 
 85         else if(strcmp(str,cmd[8])==0)
 86         {
 87             printf("type:order of inside\n");
 88             printf("copy the document");
 89             printf("\n");
 90             printf("\n");
 91             //break;
 92         }
 93 
 94         else if(strcmp(str,cmd[9])==0)
 95         {
 96             printf("order\n");     
 97             printf("dir\t check the catalogue\n");              
 98             printf("cd\t enter the catalogue\n");                
 99             printf("md\t make the new catalogue\n");              
100             printf("rd\t delete the document\n");              
101             printf("cls\t lean the screen\n");             
102             printf("date\t show or reset the date\n");          
103             printf("time\t show or reset the time\n");          
104             printf("ren\t modify the name\n");        
105             printf("copy\t copy the document\n");        
106             printf("quit\t quit\n");         
107             printf("help\t the imformation u need\n");      
108             printf("\n");
109         }
110 
111         else if(strcmp(str,cmd[10])==0) 
112         {    
113             return; 
114         }
115    
116         else  
117         {   
118             printf("the order is wrong\n");    
119             printf("\n");
120         }
121 }
122 }

技术分享

 

二、 实验总结

心得体会:对于大一c语言没学好的我来说,刚开始无从下手,但是通过室友的帮助总算完成任务了,在这过程中,学到了最基本的c语言结构。

 

实验1

标签:

原文地址:http://www.cnblogs.com/lsh43/p/4601656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!