I'm very new to C++, so this code is just basically C compiled with g++. It works when I compile it on Windows but it does a core dump on Linux. Can anyone see what I'm doing wrong?
Here is more of the code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "student.h"
#define MAX_LINE_LENGTH 200
#define DELIMITER ','
struct _node
{
    StudentRecord student;
    struct _node  *next;
};
typedef struct _node Node;
int main(int argc, char* argv[])
{
    if (argc != 2)
    {
        fprintf(stderr, "Usage: demo studentdata_2.txt\n");
        return 1;
    }
    FILE* fp = fopen("studentdata_2.txt", "r");
    if (!fp)
    {
        fprintf(stderr, "Cannot read file\n");
        return 2;
    }
    char  line[MAX_LINE_LENGTH + 1];
    Node *head = 0; 
    Node *latest;
    fgets(line, MAX_LINE_LENGTH, fp);
    printf("reaches here\n");
    while (!feof(fp))
    {
        if (strlen(line) >= 3)
        {
            Node *current = (Node*)malloc(sizeof(Node));
            current->next = 0;
            if (!head) 
                head = current;
            else
                latest->next = current;
            latest = current;
            parseStudent(line, DELIMITER, ¤t->student);
        }
        fgets(line, MAX_LINE_LENGTH, fp);
    }
    fclose(fp);
    printf("doesn't reach here\n");
    int count = 0;
    float sum = 0;
    Node* ptr = head;
    while (ptr)
    {
        count++;
        sum += ptr->student.m_score;
        ptr = ptr->next;
    }
    float average = sum / count;
    ptr = head;
    ptr = head;
    while (ptr)
    {
        releaseStudent(&ptr->student);
        Node* nxt = ptr->next;
        free(ptr);
        ptr = nxt;
    }
    return 0;
}
