linux³ÌÐò´ò²»¿ªÍ·Îļþ
#include <fcnt1.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
int fd_open,fd_open_create,fd_create;
if((fd_open=open("/home/wang/test/hello.c",O_RDONLY))==-1)
{
perror("open");
exit(EXIT_FAILURE);
}
printf("the file's descriptor is:%d\n",fd_open);
if((fd_open_create==open("./tmp1",O_CREAT|O_EXCL,0644))==-1)
{
perrno("open");
exit(EXIT_FAILURE);
}
printf("the tmp1 file descriptor is:%d\n",fd_open_create);
if((fd_create=creat("./tem2",0644))==-1)
{
perrno("create");
exit(EXIT_FAILURE);
}
printf("the tmp2 file descriptor is:%d\n",fd_create);
close(fd_open);
close(fd_create);
close(fd_open_create);
return 0;
}
±àÒë½á¹û
wangjun@my-desktop:~/test$ gcc -ggdb3 -o open_example open_example.c
open_example.c:1:19: ´íÎó£º fcnt1.h£ºÃ»ÓиÃÎļþ»òĿ¼
open_example.c: ÔÚº¯Êý¡®main¡¯ÖÐ:
open_example.c:8:
Ïà¹ØÎÊ´ð£º
дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
ΪʲôÎÒ ioctl(fd,I2C_SLAVE,0x50) ÕýÈ·£¬¶ø½«0x50¸Ä³ÉÆäËûµØÖ·¶¼³ö´í£¿
ÊDz»ÊÇÿÔö¼ÓÒ»¸öI2CÆ÷¼þ£¬ÒªÐÞ¸ÄÄں˴úÂ룿
¡£¡£¡£×Ô¼º½â¾öÁË¡£¡£²»Í¬I2CµØÖ·£¬ÒªÖØÐÂopen¡£¡£
²»¹ýҲлл¥Éϵģ¬ËÍ·ÖÁË
......
д³öÍê³ÉÒÔϹ¦ÄܵÄLinuxÃüÁî:
1) ÔÚµ±Ç°Ä¿Â¼¼°Æä×ÓĿ¼ËùÓеÄ.cppÎļþÖвéÕÒ×Ö·û´®"example", ²»Çø·Ö´óСд;
2) ʹÓÃsedÃüÁî, ½«ÎļþxyzÖеĵ¥´ÊAAAÈ«²¿Ì滻ΪBBB;
3) ÓÃÒ»ÌõÃüÁî´´½¨aa bb ccÈ ......
ÎÒÏÖÔÚÓõÄÊÇdpch ½øÐÐÅäÖõÄ
Perl code:
abc ~ # ifconfig
eth0 Link encap:Ethernet HWaddr 00:1e:ec:c1:94:75
inet addr:10.2.0.144 Bcast:10.2.1.255 Mask:255.255.254.0
......
chmodÖеÄmode_t²ÎÊý£¬ÈçºÎ¶¯Ì¬µÄ´«ÈëÖµ£¬ÀýÈç ÎÒÒª´«Èë0777»ò0444£¬µ«ÎÒÊäÈëµÄÊÇ×Ö·û´® Ôõôת»¯Îª8½øÖÆ
ÿ¸öģʽ¾ùÔ¤¶¨ÒåÓк꣬ÓÖÒòΪÆäʵ¿ÉÑ¡·ÖÖ§ÓÐÏÞ£¬Äã¿ÉÒÔÅжÏÊäÈëµÃ×Ö·û´®£¬Ê¹ÓÃswicthÖ®ÀàµÃ°ì·¨£¬¸øÒ»ÁÙʱ ......