• 大小: 1KB
    文件类型: .c
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: C/C++
  • 标签: shell  

资源简介

该程序是我写的博客“一起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

评论

共有 条评论