All pastes #365976 Raw Edit

virus

public c v1 · immutable
#365976 ·published 2007-02-21 12:08 UTC
rendered paste body
#include <stdio.h>#define MAXCHAR 200main(int argc, char **argv) // argv is a list of pointers to char arrays, so pointer to array of pointers{        FILE *fp[argc-1];        int x = 0;        int y;        char s[MAXCHAR];        while(x < argc-1) { // the first argument is the executable so argc is 1 larger than the number of arguments given                fp[x] = fopen(*++argv, "r"); // fp[x] is type of FILE*, fopen returns FILE* don't convert it to char*                if(fp[x] == NULL) {                   fprintf(stderr, "ERROR: Kan bestand %s niet openen\n", argv);                                      exit(1);                }                y = 1;                printf("Bestand: %s\n", argv);                while(fgets(s, MAXCHAR, fp[x]) != NULL) {                        printf("%d: %s", y, s);                        y++;                }                printf("\n\n\n");                x++;        }}