16.htm ( File view )

  • By 2010-08-02
  • View(s):4
  • Download(s):0
  • Point(s): 1
			

Untitled Document






getoptв
غ

ͷļ
#include<unistd.h>
int getopt(int argc,char * const argv[ ],const char * optstring);
˵
getopt()вargcargvmain()ݵIJݡoptstring ѡַ˺᷵argv һѡĸĸӦoptstring еĸѡַĸðš:ʾصIJȫoptarg ָ˶getopt()ҲϵIJӡϢȫoptoptΪ?ַϣgetopt()ӡϢֻҪȫopterrΪ0ɡ
ֵ
ҵϵIJ򷵻ش˲ĸڲoptstring ѡĸ򷵻ء?ַ򷵻-1
#include<stdio.h>
#include<unistd.h>
int main(int argc,char **argv)
{
int ch;
opterr = 0;
while((ch = getopt(argc,argv,a:bcde))!= -1)
switch(ch)
{
case a:
printf(option a:%s\n,optarg);
break;
case b:
printf(option b :b\n);
break;
default:
printf(other option :%c\n,ch);
}
printf(optopt +%c\n,optopt);
}
ִ
$./getopt Cb
option b:b
$./getopt Cc
other option:c
$./getopt Ca
other option :?
$./getopt Ca12345
option a:12345



isattyжļǷΪն˻
غ
ttyname
ͷļ
#include<unistd.h>
int isatty(int desc);
˵
descļΪһն˻򷵻1򷵻0
ֵ
ļΪն˻򷵻1򷵻0
οttyname()



selectI/O๤ƣ
ͷļ
#include<sys/time.h>
#include<sys/types.h>
#include<unistd.h>
int select(int n,fd_set * readfds,fd_set * writefds,fd_set * exceptfds,struct timeval * timeout);
˵
select()ȴļ״̬ĸı䡣nļʼ1readfdswritefds exceptfds Ϊ飬شʵĶд״µĺṩ˴ķʽ:
FD_CLR(inr fd,fd_set* set)setfd λ
FD_ISSET(int fd,fd_set *set)setfd λǷΪ
FD_SETint fd,fd_set*setsetfdλ
FD_ZEROfd_set *set setȫλ
timeoutΪṹtimevalselect()ĵȴʱ䣬ṹ
struct timeval
{
time_t tv_sec;
time_t tv_usec;
};
... ... (Please download the complete source code to view)
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
Linux-C函数-信号处理篇.htm552.00 B19-05-08|10:27
Linux-C函数-内存及字符串操作篇.htm568.00 B19-05-08|10:27
Linux-C函数-内存控制篇.htm552.00 B19-05-08|10:27
Linux-C函数-字符串转换篇.htm556.00 B19-05-08|10:27
Linux-C函数-字符测试篇.htm552.00 B19-05-08|10:27
Linux-C函数-常用数学函数篇.htm560.00 B19-05-08|10:27
Linux-C函数-接口处理篇.htm552.00 B19-05-08|10:27
Linux-C函数-数据结构及算法篇.htm564.00 B19-05-08|10:27
Linux-C函数-文件内容操作篇.htm560.00 B19-05-08|10:27
Linux-C函数-文件操作篇.htm552.00 B19-05-08|10:27
Linux-C函数-文件权限控制篇.htm560.00 B19-05-08|10:27
Linux-C函数-日期时间篇.htm552.00 B19-05-08|10:27
Linux-C函数-环境变量篇.htm552.00 B19-05-08|10:27
Linux-C函数-用户组篇.htm548.00 B19-05-08|10:27
Linux-C函数-终端控制篇.htm552.00 B19-05-08|10:27
Linux-C函数-进程操作篇.htm552.00 B19-05-08|10:27
11.htm72.14 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
16.htm9.46 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
07.htm76.70 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
15.htm6.96 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
04.htm18.86 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
12.htm67.83 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
09.htm30.28 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
10.htm49.96 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
08.htm18.21 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
14.htm58.14 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
06.htm39.94 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
01.htm27.35 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
02.htm23.47 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
03.htm14.07 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
05.htm58.64 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
13.htm40.40 kB19-05-08|10:27
left.htm36.58 kB19-05-08|10:27
Linux-C函数-进程操作篇.files0.00 B11-08-08|17:48
Linux-C函数-终端控制篇.files0.00 B11-08-08|17:48
Linux-C函数-用户组篇.files0.00 B11-08-08|17:48
Linux-C函数-环境变量篇.files0.00 B11-08-08|17:48
Linux-C函数-日期时间篇.files0.00 B11-08-08|17:48
Linux-C函数-文件权限控制篇.files0.00 B11-08-08|17:48
Linux-C函数-文件操作篇.files0.00 B11-08-08|17:48
Linux-C函数-文件内容操作篇.files0.00 B11-08-08|17:48
Linux-C函数-数据结构及算法篇.files0.00 B11-08-08|17:48
Linux-C函数-接口处理篇.files0.00 B11-08-08|17:48
Linux-C函数-常用数学函数篇.files0.00 B11-08-08|17:48
Linux-C函数-字符测试篇.files0.00 B11-08-08|17:48
Linux-C函数-字符串转换篇.files0.00 B11-08-08|17:48
Linux-C函数-内存控制篇.files0.00 B11-08-08|17:48
Linux-C函数-内存及字符串操作篇.files0.00 B11-08-08|17:48
Linux-C函数-信号处理篇.files0.00 B11-08-08|17:48
Linux-C0.00 B11-08-08|17:48
...
Sponsored links
  • Sent successfully!
  • 1 point

16.htm (131.54 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D