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:
Ïà¹ØÎÊ´ð£º
C/C++ code:
char Time="2009-9-23";
FILE *fpOut=fopen("1.txt","w+");
if(fpOut==NULL)
return ;
fwr ......
ÇóÖú~~~~~~~~~~~ÕýÔÚ×°redhat£¬·ÖÇøÀÏÊDz»³É¹¦£¬ÓÐÈËÖªµÀô
ÏÖÔÚÓÖÒ»¸ö5G µÄntfs¸ñʽ¿ÕÅÌ£¬Ôõô×ö°¡
ÔÚÏßµÈ~
ÎÒÏÈɾ³ýÕâ¸ö·ÖÇø£¬È»ºó½¨Á¢Ò»¸ö /boot £¨102M£©£¬È»ºóÔÙʣϵĿÕÓà¿Õ¼ä½¨Á ......
ÎÒÔÚlinuxÏÂдÁ˸öUDPµÄserverºÍclientµÄ´úÂ룬
ÏÖÔÚ³öÁËÕâÑùÒ»¸öÎÊÌ⣬
serverÊÕµ½ÁËclientµÄÊý¾Ý£¬²¢»Ø¸´ÁË£¬µ«ÊÇclientÒ»Ö±ÊÕ²»µ½server»Ø¸´µÄÄÚÈÝ£¬£¬ºóÀ´ÎÒÓÃ×¥°ü¹¤¾ß½¨Á¢ÁËÒ»¸öserverÀ´Á¬½Ó֮ǰµÄcl ......
д³öÍê³ÉÒÔϹ¦ÄܵÄLinuxÃüÁî:
1) ÔÚµ±Ç°Ä¿Â¼¼°Æä×ÓĿ¼ËùÓеÄ.cppÎļþÖвéÕÒ×Ö·û´®"example", ²»Çø·Ö´óСд;
2) ʹÓÃsedÃüÁî, ½«ÎļþxyzÖеĵ¥´ÊAAAÈ«²¿Ì滻ΪBBB;
3) ÓÃÒ»ÌõÃüÁî´´½¨aa bb ccÈ ......
дÁ˸ö¼òµ¥µÄ兩Êý±È½ÏµÄ³ÌÐò£¬¿ÉÊÇgcc¾ÍÊDZàÒë²»¹ý£¬Ìáʾa.c:13: ´íÎó£º
expected ¡®=¡¯, ¡®,¡¯, ¡®;¡¯, ¡®asm¡¯ or ¡®__attribute__¡¯ before ¡®main¡¯µÄ´íÎ󣬿´ÁËÓÖ¿´¾õµÃûÓÐÓï·¨´íÎó£¬ ......