#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. css文本溢出省略号

    .ellip{ display: block; width:200px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; ...

  2. 将CachedRowSet中的数据转储到对象中

    虽然还有很多bug,但凑合能用,就是将CachedRowSet中的数据转换成对象或List.省去了繁琐难看的一系列get/set方法. 先说调用: 注: cachedRowSet是查询的结果集 Stu ...

  3. win7 备份错误解决

    解决win7 备份出错, 开启服务: windows backup volume shadow copy

  4. Java代理模式

    java代理模式及动态代理类 1.      代理模式 代理模式的作用是:为其他对象提供一种代理以控制对这个对象的访问.在某些情况下,一个客户不想或者不能直接引用另一个对象,而代理对象可以在客户端和目 ...

  5. java之数组(笔记)

    1.与c++不同的声明 int[] i, j; int i[], j; 这两种声明在c++中是同等的,但是在Java中,前者是声明两个,后者是只有i是数组. 2.数组可以看作是特殊的类 3.数组的cl ...

  6. 【iCore3 双核心板】例程二十一:LAN_TCPS实验——以太网数据传输

    实验指导书及代码包下载: http://pan.baidu.com/s/1ntTjWpV iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...

  7. A trip through the Graphics Pipeline 2011_08_Pixel processing – “fork phase”

    In this part, I’ll be dealing with the first half of pixel processing: dispatch and actual pixel sha ...

  8. json.parse 与 json.stringfy

    转自 :http://blog.csdn.net/wangxiaohu__/article/details/7254598 parse用于从一个字符串中解析出json对象,如 var str = '{ ...

  9. windows查看端口命令

    netstat -ano 查看所有端口 netstat -ano|findstr "1935" 查看1935端口占用PID tasklist|findstr "PID”

  10. 如何使用Jquery自定义命名空间namespace

    // 把生成命名空间的方法绑定在jQuery上 jQuery.namespace = function () { var a = arguments, o = null, i, j, d; for ( ...