Annotation of gpl/axl/test/read-codes.c, revision 1.1.1.1
1.1 misho 1: #include <stdio.h>
2:
3: int main (int argc, char ** argv)
4: {
5: FILE * file;
6: char buffer[1];
7: int iterator;
8: int item_found = 1;
9:
10: if (argc != 2) {
11: printf ("Please provide a file..\n");
12: return -1;
13: }
14:
15: file = fopen (argv[1], "r");
16: if (file == NULL) {
17: printf ("failed to open: %s..\n", argv[0]);
18: return -1;
19: }
20:
21: iterator = 0;
22: item_found = 0;
23: while (fread (buffer, 1, 1, file) == 1) {
24: if (buffer[0] == '\n'){
25: printf ("\n");
26: if (item_found) {
27: iterator++;
28: item_found = 0;
29: }
30: } else {
31: printf ("iterator=%d: value: %d, %c ", iterator, (unsigned char) buffer[0], buffer[0]);
32: item_found = 1;
33: }
34:
35: }
36: fclose (file);
37: return 0;
38: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>