实验一
1 #include<stdio.h> 2 #include<string.h> 3 void main() /*主函数*/ 4 { 5 char *b[11]={"dir","cd","md","rd","cls","date","time","ren","copy","help", "quit"}; /*指针数组存储关键字*/ 6 int pan(char ch1[],char *j[11]); 7 char a[10],*p=a; 8 printf("Welcome.........\nPleas enter a command!\nEnter 'quit' to quit.\nFor help,Enter 'help'.\n"); 9 c1: printf("c:\>$"); 10 scanf("%s",a); 11 pan(p,b); /*函数调用*/ 12 if(strcmp(a,b[10])!=0) /*比较输入的字符串是否quit结束命令*/ goto c1; 13 else printf("out of work!!\n"); 14 } 15 int pan(char ch1[],char *j[11]) /*子函数*/ 16 { 17 int i; 18 for( i=0;i<11;i++) 19 if(strcmp(ch1,j[i])==0) /*比较输入的字符串与数组的关键字是否相等*/ 20 { 21 switch(i) 22 { 23 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; 24 case 1:printf("command name is cd.\nIt's function is change directory.\nIt's an internal command.\n");break; 25 case 2:printf("command name is md.\nIt's function is creat a new directory.\nIt's an internal command.\n");break; 26 case 3:printf("command name is rd.\nIt's function is delete a directory which is empty.\nIt's an internal command.\n");break; 27 case 4:printf("command name is cls.\nIt's function is clean screen\nIt's an internal command.\n");break;
28 case 5:printf("command name is date.\nIt's function is show date.\nIt's an internal command.\n");break; 29 case 6:printf("command name is time.\nIt's function is shio time.\nIt's an internal command.\n");break; 30 case 7:printf("command name is ren.\nIt's function is rename a file.\nIt's an internal command.\n");break; 31 case 8:printf("command name is copy.\nIt's function is copy files.\nIt's an internal command.\n");break; 32 case 9:printf("dir\tcd\tmd\trd\tcls\ndate\ttime\tren\tcopy\nEnter \" quit\" to quit this program!!\n");break; 33 case 10:printf("Thanks for using it,bye!!\n");break;
34 } 35 return 1;} 36 printf("No this one!!\nNot a internal commal.\n");return0;
37 }
![](http://images0.cnblogs.com/blog2015/739215/201504/061848484151492.png)
心得:
这个学期第一次做的实验,不是很好,很多东西不是很懂。