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