0

have problem copying the string in array into the linked list

typedef struct{
    char census_year[MAX_VAL_LEN + 1];
} data_info_t;

/* struct of node */
typedef struct node node_t;
struct node{
    data_info_t *info;
    node_t *next;
};

char info_string[MAX_LINE_LEN];

/*escape the first line */ fgets(info_string, MAX_LINE_LEN, fp);

/* separate the data put them into node and them put the node into the list */
while(fgets(info_string, MAX_LINE_LEN, fp) != NULL) {

    char *ptr = strtok(info_string, ",");
    
    strcpy(one_line->info->census_year, ptr);
}

0 Answers0