软件工程网络课程作业二:命令行菜单小程序
2017-09-18 16:19
375 查看
【clksjx + 《软件工程(C编码实践篇)》MOOC课程作业http://mooc.study.163.com/course/USTC-1000002006 】
由于在windows下习惯
实验代码
#include<stdio.h> #include<string.h> //for the strcmp() #include<stdlib.h> //for the exit() void helpCommand() { printf("Help menu:\n"); printf(" 1.function helps\n"); printf(" 2.config helps\n"); printf(" ...\n"); printf(" Please enter a number representing your choice.\n"); } void functionHelps() { printf("This command is for the function helps."); } void configHelps() { printf("This command is for the config helps."); } void helloCommand() { printf("Hello there! This command is just for testing.\n"); } void exitCommand() { exit(0); } void errorCommand() { printf("Please input a valid command!"); } int main() { char cmd[128]; while(1) { scanf("%s", cmd); if(strcmp(cmd, "help") == 0) { helpCommand(); } else if(strcmp(cmd, "hello") == 0) { helloCommand(); } else if(strcmp(cmd, "exit") == 0) { exitCommand(); } else if(strcmp(cmd, "1") == 0) { functionHelps(); } else if(strcmp(cmd,"2") == 0) { 8865 configHelps(); } else { errorCommand(); } } return 0; }
实验结果
遇到的问题及解决方法
vi不显示当前的模式状态。因为ubuntu默认安装的vi是不完整的,可以在命令行模式下输入set showmode来设置显示当前模式。
由于在windows下习惯
Ctrl+s进行保存, 导致系统没有反应。因为在Linux中
Ctrl+s是暂停系统的快捷键,可以通过按
Ctrl+q恢复虚拟机工作状态。
相关文章推荐
- 软件工程网络课程作业一:Hello, world!
- [高级软件工程实验]用callback增强链表模块来实现命令行菜单小程序V2.8
- [高级软件工程实验]命令行菜单小程序V1.0
- [高级软件工程实验]用可重用的链表模块来实现命令行菜单小程序V2.5
- [高级软件工程实验]内部模块化的命令行菜单小程序V2.0
- 软件工程网络15个人阅读作业1(201521123032 黄登峰)
- 软件工程作业—编写四则运算的程序
- 小飞鱼网络平台课程 OA开发程序基础课 2月15日 第一课 HTML基础课件及作业
- 软件工程作业-采访本课程往届学生记录
- 软件工程网络15个人阅读作业1
- 软件工程网络15个人阅读作业1(201521123111 陈伟泽)
- 软件工程课程前三次作业总结
- 软件工程网络15个人阅读作业1(201521123052 蓝锦明)
- 软件工程课程作业(一)—20道随机四则运算题(C++)
- 软件工程网络15个人阅读作业1(201521123108 余腾鑫)
- 软件工程网络15个人阅读作业1(201521123049 杨泽斌)
- 软件工程网络15个人阅读作业1 201521123056 吴剑通
- 软件工程课程作业(四)--返回一个整数数组中最大子数组的和
- 软件工程网络15个人阅读作业1(201521123082 黄华林)
- 软件工程网络15个人阅读作业1