/* Author : Rick van der Zwet * S-number : 0433373 * Version : $Id: compressie.cc 330 2007-11-25 23:31:30Z rick $ * Copyright : FreeBSD Licence */ #include #include #include #include #include "fileio.h" //XXX: File are only checked at creation time, not during execution int main(int argc, char ** argv) { FILE * input; FILE * output; int number = 0; int row = 0; if (argc < 2) { fprintf(stderr, "Usage: %s []\n",argv[0]); return(EX_USAGE); } input = fopen(argv[1], "r"); if (input == NULL) { fprintf(stderr,"Error: Unable to use `%s', errno: %i\n", argv[1], errno); return(EX_NOINPUT); } if (argc == 3) { output = fopen(argv[2], "w"); if (output == NULL) { fprintf(stderr,"Error: Unable to use `%s', errno: %i\n", argv[2], errno); return(EX_CANTCREAT); } } else output = stdout; while ((number = fetchnumber(input)) != FILE_END) { fprintf(output,"%04i ", number); row++; if (row == 15) { printf("\n"); row = 0; } } fprintf(output,"\n"); fclose(input); fclose(output); return(EX_OK); }