컴퓨터 이야기
리눅스에서 2기가 이상 파일 쓰는 방법
CatchMeIfYouCan
2013. 5. 10. 11:20
- #define _FILE_OFFSET_BITS 64
- #include<stdio.h>
- int main(void){
- char c[]="abcdefghij";
- size_t rez;
- FILE*f = fopen("filldisk.dat","wb");
- while(1){
- rez = fwrite(c,1,sizeof(c), f);
- if( rez <sizeof(c)){break;}
- }
- fclose(f);
- return0;
- }
위와 같이 stdio.h를 include 하기 전에 _FILE_OFFSET_BITS를 64로 define 해준다.
makefile에서 -D_FILE_OFFSET_BITS=64 로 정의해도 된다.