목차
1. 문제정의
2. 문제분석
3. Design
4. 결과화면
5. 결론 및 소감
6. Source
2. 문제분석
3. Design
4. 결과화면
5. 결론 및 소감
6. Source
본문내용
s/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);
}
#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);
}
추천자료
사이버음란물의 유통과 규제
국내 방송 프로그램의 일본프로그램 모방
이동통신 업체의 MP3 파일 이용문제
P2P 사업의 방향과 전망
유닉스에서 소켓 프로그래밍을 이용한 서버/클라이언트 무선랜 파일 전송 프로그램 (A server...
[C 프로그래밍] C로 배우는 프로그래밍 기초 1장 이해점검 및 프로그램문제 풀이
[c 프로그램 레포트] 자동 업데이트 프로그램 c프로그래밍
[클리퍼][프로그래밍언어][프로그램언어][프로그래밍]프로그래밍언어(프로그램언어)의 발전 ...
헌법상의 음란에 대한 개념과 사이버 공간에서의 음란규제 입법
정보보호 정의, 목적, 피해 사례
인터넷 정보통신 용어 정리
1장. 리눅스의 기본 개념과 프로그램 작성 연습문제
MFC와 OpenCV 패턴인식을 이용한 커플 추천 프로그램 (Couple Maker ver 2.02)