0

I have to use getline() to read a file for a class and just cant get this figured out. Right now I'm just trying to loop through the file to determine how big my dynamic array needs to be. The file I'm trying to read is in the same folder as the .c file so I don't think its a opening issue but I really have no idea. Thanks in advance.

int SCAN(FILE *(*stream)) {
    int size = 0;
    char* buffer = NULL;
    FILE* data = fopen("./hw4.data", "r");
    while (1) {
        getline(&buffer, 32, data);
        if (feof(data)) break;
        size++;
    }
    
    printf("done");
    // Free the allocated line buffer and close the file
    //free(line_buf);
    //line_buf = NULL;
    fclose(data);

    return size;
}

Here's the error:

Errors

FunkyMunky
  • 21
  • 5

0 Answers0