#include <stdio.h>
#include <error.h>
#define BUF_SIZE 256

int main(int argc, char **argv)
{
  FILE *in_file, *out_file;
  char rec[BUF_SIZE];
  size_t bytes_in, bytes_out;
 
  if( argc != 3 )
  {
    printf("Useage : %s file1 file2\n", argv[0]);
    return 1;
  }
 
  in_file = fopen( argv[1], "rb" );
  if( in_file == NULL )
  {
    printf( "File open Error!, %s", argv[1] );
    return 2;
  }
 
  out_file = fopen( argv[2], "wb");
  if( out_file == NULL )
  {
    printf( "File open Error!, %s", argv[2] );
    return 3;
  }
 
  while( (bytes_in = fread( rec, 1, BUF_SIZE, in_file )) > 0 )
  {
    bytes_out = fwrite( rec, 1, BUF_SIZE, out_file );
    if( bytes_out != bytes_in )
    {
      perror( "Fatal Write Error!" );
      return 4;
    }
  }
 
  fclose( out_file );
  fclose( in_file );
 
  return 0;
} 
 
2006/05/14 00:01 2006/05/14 00:01

글 걸기 주소 : 이 글에는 트랙백을 보낼 수 없습니다

덧글을 달아 주세요