无法通过使用strcpy将字符串复制到链接列表中

问题描述

将数组中的字符串复制到链接列表时遇到问题

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];

/ *转义第一行* / 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);
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)