資源簡介
該程序是我寫的博客“一起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命令
評論
共有 條評論