Ticket #371: fread.c
File fread.c, 356 bytes (added by , 13 years ago) |
---|
Line | |
---|---|
1 | |
2 | #include <stdio.h> |
3 | |
4 | int main(int argc, char ** argv) |
5 | { |
6 | if (argc == 1) { |
7 | printf("missing argument!/n"); |
8 | return 1; |
9 | } |
10 | |
11 | char buf[512]; |
12 | FILE * fp; |
13 | size_t count; |
14 | |
15 | fp = fopen(argv[1], "r"); |
16 | if (fp == NULL) { |
17 | printf("error on opening!"); |
18 | return 2; |
19 | } |
20 | |
21 | count = fread(buf, 512, 1, fp); |
22 | printf("read %d bytes.", count); |
23 | |
24 | fclose(fp); |
25 | |
26 | return 0; |
27 | } |