0

I am attempting to layout an array of character pointers from a file. Here is my attempt:

    char c; //in_file is a FILE object
    char** mazestring = malloc(sizeof(char*));
    while((c = fgetc(in_file)) != EOF) {
            mazestring = realloc(mazestring,sizeof(char*)+sizeof(mazestring));
            char *cp = malloc(sizeof(char*));
            *cp = c;
    }

When i wrote this code, i was unsure so pardon the nooby code. I keep getting a seg fault whenever i attempt to run.

Adam G.
  • 107
  • 1
  • 8

0 Answers0