| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1674 人关注过本帖
标题:C语言read()函数读取BUFFER问题
只看楼主 加入收藏
bindy
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-12-27
收藏
 问题点数:0 回复次数:0 
C语言read()函数读取BUFFER问题
在本本上调试这个程序发现的一些问题。本人实在难以想明,特发出请教。源码如下:
#include "stdio.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"


main(){
    int source_fp,target_fp,num;
    char Buff[50];
    if((source_fp=open("hello.c",O_RDONLY))==-1)
    printf("the source file open error\n");
    if((target_fp=open("hello1.c",O_WRONLY|O_CREAT,0777))==-1)
    printf("the target file open error\n");
   
    while((num=read(source_fp,Buff,50))>0)
    if(write(target_fp,Buff,50)!=num){
        printf("the target file write error\n");
        return 4;
    }   
    close(source_fp);
    close(target_fp);
    return 0;
    charget();
}   

hello.c文件内容:
#include "stdio.h"



static int j;
void fun1(){
       static int i=0;
       i++;
}


void fun2(){
    j=0;
    j++;
}
   
   
      
main(){
   for(int k=0; k<10; k++){
       fun1();
       fun2();
   }
   return 0;        
}

运行程序后hello1.c内容:
#include "stdio.h"



static int j;
void fun1 fun1


为何会出现这种情况?CPU是I3型号的。
搜索更多相关主题的帖子: BUFFER 函数 
2010-09-15 00:46
快速回复:C语言read()函数读取BUFFER问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017595 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved