blob: 65f0a9e12a032565e2a363fbbb8bce1c2d63377a (
plain)
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
31
32
33
34
|
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
FILE* source;
FILE* target;
int i;
for (i = 1; i < argc; ++i) {
if (strcmp(argv[i], "-bad") == 0) {
fprintf(stdout, "stdout from bad command line arg '-bad'\n");
fprintf(stderr, "stderr from bad command line arg '-bad'\n");
return 1;
}
}
source = fopen(argv[argc - 1], "rb");
if (source == NULL) {
return 1;
}
target = fopen(argv[argc - 2], "wb");
if (target != NULL) {
char buffer[500];
size_t n = fread(buffer, 1, sizeof(buffer), source);
fwrite(buffer, 1, n, target);
fclose(source);
fclose(target);
return 0;
}
return 1;
}
|