Linux程序设计 终端
对终端进行读写
在编写程序时,我们往往需要从终端读入数据。一种情况是需要连续地读入用户键入的选择项,这往往出现在数据库程序中。程序员往往会使用
getchar
函数来读取数据,继而判断输入的数据是否有效,从而做出反应。其实如此做带有很大的风险,一个实例程序如下
#include <stdio.h>
char *menu[] = {
"a - add new record",
"d - delete record",
"q - quit",
NULL
};
int getchoice(char *choices[]){
int chosen = 0;
int selected;
char **option;
do {
option = choices;
while(*option){
printf("%s\n", *option);
option++;
}
selected = getchar();
option = choices;
while(*option){
相关文档:
Linux 下串口编程入门
文档选项
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td><td width="16"><img alt="" width="16"
heig ......
http://wiki.chinaunix.net/index.php/Linux
--------------------获得帮助 : man和info使用 --------------------
因为同一个命令可能属于几个section,如open:就既有命令的open,程序函数的open,等等。每一个section有一个section号。
man -aw <命令>&n ......
Securing your Linux server is important to protect your data, intellectual property, and time, from the hands of crackers (hackers). The system administrator is responsible for security Linux box. In this first part of a Linux server security series, I will provide 20 hardening tips for default inst ......
用rpm包安装的MySQL是不会安装/etc/my.cnf文件的,
至于为什么没有这个文件而MySQL却也能正常启动和作用,在点有两个说法,
第一种说法,my.cnf只是MySQL启动时的一个参数文件,可以没有它,这时MySQL会用内置的默认参数启动,
第二种说法,MySQL在启动时自动使用/usr/share/mysql目录下的my-medium.cnf文件,这种说法仅 ......
<!--
@page { margin: 2cm }
P { margin-bottom: 0.21cm }
-->
在我们国内,不少
Linux
的先行者都以失败而告终,现在,他们在哪里?怎么不出来说话了?但是,这些先行者想告诉我们什么呢?你想知道吗?
搞 ......