#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. if分支练习

    1.输入三个整数,xyz,最终以从小到大的方式输出.利用嵌套. 方法一: 方法二:   2.输入一个小于等于100的整数,判断: //是小于10的 //两位数 //是100 3.//输入学生姓名,输入 ...

  2. 繁简体 互转 js

    html: <script type="text/javascript" src="/js/s2t.js"></script><s ...

  3. BizTalk开发系列(二十二) 开发自定义Map Functoid

    尽管 BizTalk Server 提供许多Functoid以支持一系列不同的操作,但仍可能会遇到需要其他方法的情况.<BizTalk开发系列 Map扩展开发>介绍了通过使用自定义 XSL ...

  4. Python强化训练笔记(三)——词频的统计

    现有列表如下: [6, 7, 5, 9, 4, 1, 8, 6, 2, 9] 希望统计各个元素出现的次数,可以看作一个词频统计的问题. 我们希望最终得到一个这样的结果:{6:2, 7:1...}即 { ...

  5. Java网络通信初步认知

    本文转载自:http://wing011203.cnblogs.com/ 在这篇文章里,我们主要讨论如何使用Java实现网络通信,包括TCP通信.UDP通信.多播以及NIO. TCP连接 TCP的基础 ...

  6. TI BLE协议栈软件框架分析

    看源代码的时候,一般都是从整个代码的入口处开始,TI  BLE 协议栈源码也不例外.它的入口main()函数就是整个程序的入口,由系统上电时自动调用. 它主要做了以下几件事情: (一)底层硬件初始化配 ...

  7. linq查询结果datetime类型转string类型

    var list = new SupplierLogic().GetSupplier(pageSize, pageIndex).Select(q => new { SupplierID = q. ...

  8. NGINX: 405 Not Allowed

    近期做一个手机端静态网站,在wcm上网站预览的时候显示正常,网站数据发布到nginx网站服务上后,发现页面有部分不显示: 正常页面: 错误页面: 进入谷歌浏览器的Developer Tools(F12 ...

  9. form submit时将__VIEWSTATE和__VIEWSTATEGENERATOR一起post到另外的页面,出现验证视图状态 MAC 失败。

    错误信息: 验证视图状态 MAC 失败.如果此应用程序由网络场或群集承载,请确保 配置指定了相同的 validationKey 和验证算法.不能在群集中使用 AutoGenerate. 原因分析: F ...

  10. 一些常见maven仓库

    <repositories> <repository> <id>spring-releases</id> <url>https://repo ...