#include <stdio.h> //getchar() putchar() printf() gets() puts() sprintf()
#include <stdlib.h> //exit() rand () srand() system() free() malloc() //int getchoice (char *greet , char *choices[]);
int getchoice (char *greet , char **choices); int main()
{
char *menu[] = {
"a - add new record",
"d - delete record",
"s - show record num ",
"q - quit",
NULL,
};
int record_num = ;
int choice = ;
do
{
choice = getchoice("Please select an action",menu);
printf("Your choice is %c \n",choice);
switch (choice)
{
case 'a':
{
printf("Add record over\n");
record_num++;
break;
}
case 'd':
{
printf("Remove a record over\n");
record_num--;
break;
}
case 's':
{
printf("The record num is %d \n",record_num);
break;
}
default:
break;
}
}
while(choice!='q');
exit();
} int getchoice (char *greet , char **choices)
{
char **option;
int chosen=; // control choice is the member of menu list
int selected;
do
{
printf("Choice: %s \n" ,greet);
option=choices;
while (*option!=NULL)
{
printf("%s\n",*option);
option++;
} do
{
selected=getchar();
}while (selected=='\n'); // solve the enter char + '\n' problem,because will cause
//next input enter the '\n' directly option =choices;
while(*option)
{
if(selected == *option[])
{
chosen=;
break;
}
option++;
}
if (!chosen)
{
printf("Incorrect choice,try again\n");
} }
while(!chosen);
return selected;
}

Linux C Programing - Terminal(1)的更多相关文章

  1. 自学Linux Shell2.2-GHOME Terminal仿真器

    点击返回 自学Linux命令行与Shell脚本之路 2.2-GHOME Terminal仿真器 GNOME Terminal是GNOME桌面环境的默认终端仿真器.很多发行版,如RHEL.Fedora和 ...

  2. Linux C Programing - Arguments(2)

    #include <iostream> #include <stdlib.h> #include <stdio.h> //printf #include <u ...

  3. 如何在linux下录制terminal操作?

    相关包: ttyrec: ttyrec is a tty recorder. Recorded data can be played back with the included ttyplay co ...

  4. linux 字符终端terminal下 ftp的配置和启用

    1. ftp组件一般不是linux的自带组件,在ubuntu 12中,就自带了ftp组件 vsftp,而在redhat 9中,就没有自带需要从安装光盘中或下载相应的ftp的rpm包. ~$ sudo ...

  5. Linux 的终端 Terminal

    打开终端: 方式一:在全部应用中搜索Terminal 方式二:Ctrl+Alt+T 快捷方式打开终端 终端指令查询 如果忘记终端指令而只记得前几位可以只输入前几个字母后按Tab键查询 终端清屏 键入c ...

  6. First step to Signal —— in Linux C Programing

    1. What's signal 信号是软件中断,提供了一种处理异步事件的方法.(见<Unix环境高级编程>)一般使用时需包含 signal.h 库. 每个信号命名由SIG开头,实际值为正 ...

  7. 利用putty在window下控制linux的terminal、ftp传输

    google搜索putty,可能要FQ才能进入官方网站下载. 首先将虚拟机下的linux的网络适配器设置成桥接模式,并且将linux系统的firewall和iptables(防火墙关闭). firew ...

  8. LInux MySQL 端口验证

    linux suse11在terminal可以正常登录进行各种操作,在tomcat运行jdbc web程序异常: com.mysql.jdbc.exceptions.jdbc4.Communicati ...

  9. Git+VirtalBaox+Vagrant创建Linux虚拟机

    文章内容来自Udacity课程:Linux Command Line Basics--Getting Started with the Shell Your own Linux box To lear ...

随机推荐

  1. Relax NG 在Odoo中的应用

    想必有些同学一定会奇怪,Odoo是如何将模块中的XML中的诸如record.menuitem是如何被组织和定义的,以及各种field的各种属性究竟有哪些,今天,我们就来一探究竟. Relax NG:“ ...

  2. vsphere平台为win系统动态扩展磁盘

    1.关闭win虚拟机 2.在vcenter管理中加大磁盘空间 3.开启win虚拟机(此时磁盘并没有加大) 4.打开cmd命令行: 进入分区管理--->查看磁盘--->选择磁盘---> ...

  3. HDU1063 大数 java

    Exponentiation Time Limit: 2000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  4. asp.net 中 UEditor 图片和附件上传失败的处理方法

    1.0 找到 net 文件夹下面的 web.config 配置文件,注释掉如下的两句: 2.0 Uploader文件默认属性为编译,将其属性改为内容以后重新运行程序,图片上传成功. 3.0 删除 im ...

  5. thinkphp框架3.2的cookie删除问题记录

    在使用框架删除cookie时,发现cookie(null)不起作用.后来查看官网相关信息,看到了讨论http://www.thinkphp.cn/bug/2602.html

  6. PHP后门新玩法:一款猥琐的PHP后门分析

    0x00 背景 近日,360网站卫士安全团队近期捕获一个基于PHP实现的webshell样本,其巧妙的代码动态生成方式,猥琐的自身页面伪装手法,让我们在分析这个样本的过程中感受到相当多的乐趣.接下来就 ...

  7. 20145334实验三《敏捷开发与XP实践》

    实验内容 初步掌握单元测试和TDD 理解并掌握面向对象三要素:封装.继承.多态 初步掌握UML建模 熟悉S.O.L.I.D原则 了解设计模式 实验步骤 1.敏捷开发与XP 敏捷开发(Agile Dev ...

  8. PHPExcel创建文件格式写入对象实例

    首先到http://www.codeplex.com/PHPExcel下载PHPExcel 下面就是php导出excel的程序 <?phpini_set("display_errors ...

  9. IOS第18天(7,CAKeyframeAnimation-图标抖动)

    *** #import "HMViewController.h" #define angle2radian(x) ((x) / 180.0 * M_PI) @interface H ...

  10. Sharepoint 2013 发布功能(Publishing features)

    一.默认情况下,在创建网站集时,只有选择的模板为‘ Publishing Portal(发布门户)’与‘ Enterprise Wiki(企业 Wiki)’时才默认启用发布功能,如下图所示: 二.发布 ...