实验报告_ASE_lab2

来源:互联网 发布:胡雪岩 盛宣怀 知乎 编辑:程序博客网 时间:2024/06/05 03:34

实验题目:命令行菜单小程序

实验目的:加强代码规范习惯

实验步骤:

  1. 使用vim编辑器编写C程序,源代码在文末。
  2. 可在vim中设置tab代表的空格数:
    输入命令:

    :e ~/.vimrc

    打开文件进行配置

  3. 编译运行,测试结果
    这里写图片描述

  4. 提交git
    这里写图片描述
    Coding版本库地址

附:menu.c源代码

#include <stdio.h>#include <stdlib.h>int main(){    char cmd[128];    while (1)    {        scanf("%s",cmd);        if(strcmp(cmd,"help") == 0)        {            printf("You have typed 'help'.\n"                "This is the command list:\n"                "command1\n"                "command2\n"                "command3\n"                "command4\n"                "command5\n"                "command6\n"                "command7\n"                "command8\n"                "quit\n"                );        }        else if(strcmp(cmd,"quit") == 0)        {            exit(0);        }        else if(strcmp(cmd,"command1") == 0)        {            printf("This is command1.\n");        }        else if(strcmp(cmd,"command2") == 0)        {            printf("This is command2.\n");        }        else if(strcmp(cmd,"command3") == 0)        {            printf("This is help command3.\n");        }        else if(strcmp(cmd,"command4") == 0)        {            printf("This is help command4.\n");        }        else if(strcmp(cmd,"command5") == 0)        {            printf("This is help command5.\n");        }        else if(strcmp(cmd,"command6") == 0)        {            printf("This is help command6.\n");        }        else if(strcmp(cmd,"command7") == 0)        {            printf("This is help command7.\n");        }        else if(strcmp(cmd,"command8") == 0)        {            printf("This is help command8.\n");        }        else        {            printf("wrong command!\n");        }    }    return 0;}
原创粉丝点击