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

实验一 总结

时间:2015-04-09 10:22:42      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:

#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;
}

技术分享

总结:还好,不算难。

实验一 总结

标签:

原文地址:http://www.cnblogs.com/123hcl/p/4408822.html

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