我在 C 中使用 getline() 函数,当我多次使用它时,它一直给我段错误,就像在数组中一样。这是我写它的方式:
temp = (char *)malloc(sizeof(char)*clen);
read = getline(&temp, &clen, stdin);
tn = strtok(temp, ",");
strcpy(travel[tripnum].name, tn);
tn = strtok(NULL, ",");
travel[tripnum].country = tn;
free((void *) temp);
如果我声明不正确,请告诉我