file copy 프로그램
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

소개글

file copy 프로그램에 대한 보고서 자료입니다.

목차

1. 문제정의

2. 문제분석

3. Design

4. 결과화면

5. 결론 및 소감

6. Source

본문내용

sys/types.h>
#include // 시간함수를 사용하기 위한 헤더파일
int main(int argc, char **argv){ // 인자로 복사할 파일과 붙여 넣을 파일명을 입력받는다
FILE *in, *out; // 파일 포인터 in 과 out
char *s;
char str[100];
int c;
double time;
struct timeval start, finish;
struct timezone start_tz, finish_tz;
if(argc !=3){
write(2, \"Usage: append src.txt dest.txt\\n\", 31);
exit(1);
}
in = fopen(argv[1], \"r\"); // 복사할 파일을 읽기전용으로 연다
out = fopen(argv[2], \"w\"); // 붙여넣을 파일을 쓰기전용으로 연다
long buff=sizeof(in);
int sel=0;
// 메뉴를 사용자에게 출력하여 보여준다
printf(\"=========select menu===========\\n\");
printf(\"2. one line copy\\n\");
printf(\"3. buffer copy\\n\");
printf(\"4. exit\\n\");
printf(\"===============================\\n\");
scanf(\"%d\",&sel); // 메뉴번호 입력 받는다.
switch(sel){ // 메뉴번호에 따라 다음과 같이 실행
case 1: // 메뉴번호 1일 경우 1byte 단위로 파일을 복사한다.
printf(\"Now coping ...\\n\");
gettimeofday(&start,&start_tz); // 복사 시작 시간
while((c=fgetc(in)) != EOF) {
fputc(c, out);
}
gettimeofday(&finish,&finish_tz); // 복사 완료시간
time=((finish.tv_usec) - (start.tv_usec)); // 복사시간을 time에 넣는다
printf(\"copy time : %f micro seconds\\n\", time); // 복사시간 time을 출력
break;
case 2: // 메뉴번호 2일 경우 1line 단위로 파일을 복사한다.
gettimeofday(&start,&start_tz);
printf(\"Now coping ...\\n\");
while((s=fgets(str, 100, in))) {
fputs(str, out);
}
gettimeofday(&finish,&finish_tz);
time=((finish.tv_usec) - (start.tv_usec));
printf(\"copy time : %f micro seconds\\n\", time);
break;
case 3: // 메뉴번호 3일 경우 버퍼 단위로 파일을 복사한다.
printf(\"Now coping ...\\n\");
gettimeofday(&start,&start_tz);
if(fread(out,1,buff,in) != buff){
printf(\"Copy error !\");
exit(3);
}
gettimeofday(&finish,&finish_tz);
time=((finish.tv_usec) - (start.tv_usec));
printf(\"copy time : %f micro seconds\\n\", time);
break;
case 4:
printf(\"bye !\");
break;
}
fprintf(out, \"copy time : %f micro seconds\\n\", time); // 파일에 복사시간을 넣는다
fclose(in);
fclose(out);
exit(0);
}

키워드

  • 가격1,500
  • 페이지수8페이지
  • 등록일2011.04.28
  • 저작시기2010.10
  • 파일형식한글(hwp)
  • 자료번호#672672
본 자료는 최근 2주간 다운받은 회원이 없습니다.
다운로드 장바구니