-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
30 lines (27 loc) · 736 Bytes
/
main.c
File metadata and controls
30 lines (27 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <string.h>
#include "str.h"
int main (int argc, char *argv[])
{
char str[MAX_STR_LEN+1], guess[MAX_STR_LEN+1];
int k;
FILE *fp1;
if(argc != 3) { fprintf(stderr, "사용법: %s 파일 key\n", argv[0]);
return 1;
}
fp1 = fopen(argv[1], "r");
if(fp1 == NULL) { fprintf(stderr, "파일 %s 열기 오류\n", argv[1]);
return 2;
}
k = strlen(argv[2]);
if(k < 2) { fprintf(stderr, "키 %s는 두 자리 이상이어야 함.\n", argv[2]);
return 3;
}
while (fgets(str, MAX_STR_LEN, fp1) != NULL ) {
printf("%s", str);
encrypt(str, guess, argv[2]);
printf("-> %s", guess);
printf("\n");
}
return 0;
}