标题: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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-320451-1-1.html




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

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