如何解决无法通过使用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 举报,一经查实,本站将立刻删除。