资源简介
该程序是我写的博客“一起talk C栗子吧(第七十一回:C语言实例--DIY shell)”的配套程序,共享给大家使用
代码片段和文件信息
/* **************************
* The main funtion of shell
* *************************/
#include
#define BUF_SIZE 64
typedef struct _input_type
{
char * str; // the value of input
int size; // the length of value
}input_type;
input_type input[] =
{
{“exit“4}
{“cd“2}
{“ls“2}
};
void cds(const char * p);
void lss(const char * p);
int main(int argc char *argv[])
{
char buf[BUF_SIZE];
int res = 1;
int flag = 1;
int index = 0;
while(flag)
{
printf(“|->“);
if(NULL == fgets(bufBUF_SIZEstdin))
return 0;
index = sizeof(input)/sizeof(input_type);
while(ind
- 上一篇:VC++利用消息机制在两个EXE程序间通信
- 下一篇:C:DIY cd命令
评论
共有 条评论