学习使用的PL/0编译器增强版PL/0plusplusCompiler(三)加入“man” 功能

来源:互联网 发布:2014网络歌曲大全 编辑:程序博客网 时间:2024/06/09 13:54

Linux中很赞的工具man,查看命令或者工具的帮助手册manual。
在PL0.h中声明help方法,

void help();

在PL0.c中实现help这个方法,

/*显示帮助文档*/void help(){    printf("\n\nPL0 plus plus Compiler:\n");    printf("编译源码:    pl0 test.pl0\n");    printf("显示帮助文档:   pl0 help\n");    printf("使用debug模式编译:    pl0 test.pl0 d  \n\n\n");}

在PL0.c中main入口处检测命令行参数help

   /*如果命令行参数是"help"那么显示帮助文档*/    if(strcmp("help",argv[1])==0){        help();        return 0;    }

用命令编译PL0.c

gcc PL0.c -o pl0

运行

./pl0 help

效果图:
这里写图片描述

0 0
原创粉丝点击