几个Linux C函数的测试小程序

/*输出错误字符串
#include
#include
int main(void){
int i;
for (i=0; i<10; i++)
printf(“%d : %sn”,i,strerror (i));
}
*/
/*创建字符链接
#include
#include

int main(void){
symlink(“/media/sda6/movie”, “movie”);
return 0;
}
*/
/*改变当前目录
#include
#include
#include
#include
#include

int main(void){
int fd;
printf(“current working directory : %sn”, getcwd (NULL,(int) NULL) );
fd = open (“/home/kongove”,O_RDONLY);
fchdir (fd);

printf(“current working directory : %sn”, getcwd (NULL,(int) NULL) );
close (fd);
return 0;
}*/
/*获取当前时间
#include
#include

int main(void){
struct timeb tp;
ftime(&tp);
printf(“time:%dn”, (int)tp.time);
printf(“millitm:%dn”, tp.millitm);
printf(“timezone:%dn”, tp.timezone);
printf(“dstflag:%dn”, tp.dstflag);
return 0;
}
*/
/*获取密码*/
#include
#include

int main(void){
char *p;
p=getpass(“Input the Password:”);
if (!strcmp (“mypasswd”,p))
printf(“Passwd is :%sn”,p);

return 0;
}

One thought on “几个Linux C函数的测试小程序

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.