Linux C Programing - Terminal(1)
#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)的更多相关文章
- 自学Linux Shell2.2-GHOME Terminal仿真器
点击返回 自学Linux命令行与Shell脚本之路 2.2-GHOME Terminal仿真器 GNOME Terminal是GNOME桌面环境的默认终端仿真器.很多发行版,如RHEL.Fedora和 ...
- Linux C Programing - Arguments(2)
#include <iostream> #include <stdlib.h> #include <stdio.h> //printf #include <u ...
- 如何在linux下录制terminal操作?
相关包: ttyrec: ttyrec is a tty recorder. Recorded data can be played back with the included ttyplay co ...
- linux 字符终端terminal下 ftp的配置和启用
1. ftp组件一般不是linux的自带组件,在ubuntu 12中,就自带了ftp组件 vsftp,而在redhat 9中,就没有自带需要从安装光盘中或下载相应的ftp的rpm包. ~$ sudo ...
- Linux 的终端 Terminal
打开终端: 方式一:在全部应用中搜索Terminal 方式二:Ctrl+Alt+T 快捷方式打开终端 终端指令查询 如果忘记终端指令而只记得前几位可以只输入前几个字母后按Tab键查询 终端清屏 键入c ...
- First step to Signal —— in Linux C Programing
1. What's signal 信号是软件中断,提供了一种处理异步事件的方法.(见<Unix环境高级编程>)一般使用时需包含 signal.h 库. 每个信号命名由SIG开头,实际值为正 ...
- 利用putty在window下控制linux的terminal、ftp传输
google搜索putty,可能要FQ才能进入官方网站下载. 首先将虚拟机下的linux的网络适配器设置成桥接模式,并且将linux系统的firewall和iptables(防火墙关闭). firew ...
- LInux MySQL 端口验证
linux suse11在terminal可以正常登录进行各种操作,在tomcat运行jdbc web程序异常: com.mysql.jdbc.exceptions.jdbc4.Communicati ...
- Git+VirtalBaox+Vagrant创建Linux虚拟机
文章内容来自Udacity课程:Linux Command Line Basics--Getting Started with the Shell Your own Linux box To lear ...
随机推荐
- ado.net 实体类_数据访问类
实体类: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ...
- Java 中的 Characters
1.一般情况下,如果使用单一的 character 值,应该使用原始的 char 类型.比如: public class TestCharacter { public static void main ...
- zk 获取session,request,servletContext,response
(参考:http://www.dotblogs.com.tw/rockywang/archive/2010/01/13/12995.aspx) HttpServletRequest request = ...
- css中的一些兼容问题
浏览器兼容 为什么会有兼容问题? 由于市场上浏览器种类众多,而不同浏览器其内核亦不尽相同,所以各个浏览器对网页的解析就有一定出入,这也是导致浏览器兼容问题出现的主要原因,我们的网页需要在主流浏览器上正 ...
- jetBrains phpstorm/webstorm 编辑器使用诀窍
下载地址 https://www.jetbrains.com/products.html?fromMenu CTRL + F12 / COMMAND + F12 打开类中的结构 Ctrl + b / ...
- windows 7 安装 telnet
telnet 192.168.1.10 8080
- html5 调用摄像头
---移动设备--- <input type="file" capture="camera" accept="image/*" id= ...
- 【iCore3 双核心板_ uC/OS-III】例程二:任务的建立与删除
实验指导书及代码包下载: http://pan.baidu.com/s/1bD7ulK iCore3 购买链接: https://item.taobao.com/item.htm?id=5242294 ...
- Jenkins中Jelly基础、超链接、国际化
Jelly基础 参考:https://wiki.jenkins-ci.org/display/JENKINS/Basic+guide+to+Jelly+usage+in+Jenkins UI Samp ...
- mvc3升级mvc4的方法记录.
手工升级ASP.NET MVC 3项目: 一.安装ASP.NET MVC 4 二.升级ASP.NET MVC版本配置信息: 1:替换项目 Web.config 中的 System.Web.Mvc, V ...