ºìÁªLinuxÃÅ»§
Linux°ïÖú

¹ØÓÚwriteº¯ÊýÇóÖú£¡ÔÚÏߵȣ¬Ð»Ð»¸ßÊÖÃÇ

·¢²¼Ê±¼ä:2010-11-17 23:39:59À´Ô´:ºìÁª×÷Õß:zhangwenbo.k
[i=s] ±¾Ìû×îºóÓÉ zhangwenbo.k ÓÚ 2010-11-17 23:46 ±à¼­ [/i]

¿´¿´ÊÇÄÄÀï²»¶Ô°¡£¬½ñÌì¸ÕѧÁ˵ãÎļþ±à³Ì¾Í±à²»¶Ô¡£
±àÒëû´í£¬Îļþ°üÀ¨Îļþ¼Ð¶¼´´½¨ÁË£¬µ«ÊÇΪʲôbufÀïµÄÄÚÈݲ»Ð´ÔÚptest.txtÎļþÀֱ½Ó¾ÍÔÚÆÁÄ»ÉϾͳöÀ´ÁË£¬ºóÃ滹¸ú×ÅÄǸösuccess£¡
ÎÒ¾ÍÒ»Ö±µÈ£¬Ò»Ö±µÈ£¬Ö±µ½ÓÐÈ˸øÎÒÕÒ³ö´íÀ´¡£
#include
#include
#include
void main()
{
int pf;
char buf[]={"dfljsfjlsdk"};
int length;
int cf;
if(pf=creat("./ptest.txt",777)<0)
{
printf("error for creat!");
}
else
if(pf=open("ptest.txt",00070)<0)
{
printf("error for open!");
}
else
if(length=write(pf,buf,sizeof(buf))<=0)
{
printf("error for write");
}
else
{
mkdir("ctest",S_IRWXU);
if(cf=creat("./ctest/ctest.txt",777)<0)
{
printf("error for creat ctest.txt!");
}
else
printf("success!");
}
}
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 6 ÌõÆÀÂÛ

  1. xue_1103 ÓÚ 2010-11-18 10:12:13·¢±í:

    òËÆif(length=write(pf,buf,sizeof(buf))<=0)
    ÉÙÁËÒ»¶ÔÀ¨ºÅ°É£¡

  2. theset ÓÚ 2010-11-18 08:49:46·¢±í:

    °ï¶¥

  3. foxicel ÓÚ 2010-11-18 01:16:35·¢±í:

    4# zhangwenbo.k


    ÎÒÊÇ˵Äã¿ÉÒÔ°ÑÄãµÄ³ÌÐò·´¹ýÈ¥¿´¡£³öÏÖÁËscuess.
    ÄÇô³ÌÐòÖ´ÐÐÁËÕâ¸ö³ÌÐò¶Î
    else
    {
    mkdir("ctest",S_IRWXU);
    if(cf=creat("./ctest/ctest.txt",777)<0)
    {
    printf("error for creat ctest.txt!");
    }
    else
    printf("success!");
    }
    ûÓÐÖ´ÐÐÆäÉÏÒ»¸öif ¶Î
    if(length=write(pf,buf,sizeof(buf))<=0)
    {
    printf("error for write");
    }

    ÆäËüµÄÎÒ¾ÍûÓÐϸ¿´ÁË£¬Äã¿ÉÒÔ¿´¿´¡£Èç¹ûдÊý¾Ýµ½ÎļþÀïÁË£¬²»»á³öÏÖsuccessµÄ¡£

  4. zhangwenbo.k ÓÚ 2010-11-18 01:06:32·¢±í:

    2# foxicel


    ÄÇΪʲôbufÀïµÄ×Ö·û´®¾¹È»³öÏÖÔÚÆÁÄ»ÉÏÁË£¬ÒªÊDz»ÍùÎļþÀïдҲ²»ÄܳöÏÖÔÚÆÁÄ»ÉÏ°¡

  5. foxicel ÓÚ 2010-11-18 00:47:48·¢±í:

    1# zhangwenbo.k


    ·¢²»ÉÏÀ´Í¼Æ¬Ñ½£¬²»ºÃÒâ˼ѽ¡£

  6. foxicel ÓÚ 2010-11-18 00:39:19·¢±í:

    [i=s] ±¾Ìû×îºóÓÉ foxicel ÓÚ 2010-11-18 00:40 ±à¼­ [/i]

    ÔÚÆÁÄ»ÉϾͳöÀ´ÁË£¬ºóÃ滹¸ú×ÅÄǸösuccess£¡

    ÄÇ˵Ã÷³ÌÐòÖ´ÐÐÁËÕâ¸ö¶Î
    else
    {
    mkdir("ctest",S_IRWXU);
    if(cf=creat("./ctest/ctest.txt",777)<0)
    {
    printf("error for creat ctest.txt!");
    }
    else
    printf("success!");
    }



    ûÓÐÖ´ÐÐ
    if(length=write(pf,buf,sizeof(buf))<=0)
    {
    printf("error for write");
    }
    ËùÒÔûÓÐдÊý¾Ýµ½ÎļþÀï¡£
    ÔÙ¿´¿´Ç°ÃæµÄÌõ¼þÊÇÔõôдµÄ£¬¿ÉÄÜÊÇÌõ¼þÅжÏÄÇÀï³öÁËÎÊÌâ¡£

    ˵ÕæÓУ¬¸ñʽÓе㲻̫Ò׶Áѽ¡£