/**
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                                            

相关文章:

  • 2021-11-30
  • 2021-08-13
  • 2021-09-29
  • 2021-09-16
  • 2022-01-06
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
猜你喜欢
  • 2021-11-28
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2021-10-28
相关资源
相似解决方案