zoukankan      html  css  js  c++  java
  • ubuntu 上 新建大文件 超过2G

    /**
    author lx
    date 3.24 2011
    contact lxlenovostar@gmail.com
    biref cp a big file to anthor file.
    */

    #include
    <sys/types.h>
    #include
    <sys/stat.h>
    #include
    <fcntl.h>
    #include
    <stdlib.h>
    #include
    <unistd.h>
    #include
    <stdio.h>
    #include
    <errno.h>
    #include
    <string.h>

    #define BUFFSIZE 8192

    int main( void )
    {
    int id_write, id_read;

    id_write
    = open( "temp.pcap", O_WRONLY | O_APPEND | O_CREAT );
    id_read
    = open( "lx03.pcap", O_RDONLY );

    int n;
    char buf[BUFFSIZE];
    while ( ( n = read( id_read, buf, BUFFSIZE ) ) > 0 )
    {
    if ( write( id_write, buf, n ) != n )
    fprintf( stderr,
    "error is %s\n", strerror(errno) );
    }

    if ( n < 0 )
    printf(
    "read error\n" );

    close( id_write );
    close( id_read );

    exit(
    0 );
    }             

    编译的时候:g++ -o opencp  -D_FILE_OFFSET_BITS=64 -g opencp.cpp                                            
  • 相关阅读:
    前端知识之JavaScript内容(一)
    前端2css层叠样式表
    前端:html初识以及标签
    css
    python--re模块(正则表达式)
    python--xml模块
    关于导包问题
    前端浅了解
    试写仿优酷系统坑点
    sqlalchemy
  • 原文地址:https://www.cnblogs.com/lxgeek/p/1994230.html
Copyright © 2011-2022 走看看