我似乎無法擺脫一個額外的鏈接列表。我知道有很多方法可以做到,但我只想簡單地釋放它,因爲它是在我的循環中創建的。下面的代碼:刪除最後一個鏈接列表
current = first = malloc (sizeof (NODE));
while(fscanf(fin, "%s", current -> seq) != EOF) {
for (i = 0; i < 300; i++){
if (current->seq[i] == 'a')
current->seq[i] = 'A';
else if (current->seq[i] == 't')
current->seq[i] = 'T';
else if(current->seq[i] == 'g')
current->seq[i] = 'G';
else if(current->seq[i] == 'c')
current->seq[i] = 'C';
}
if ((current -> next = malloc (sizeof(NODE))) == NULL){
fprintf(fout, "Out of memory\nCan't add more DNA sequences\n");
return EXIT_FAILURE;
}
current = current -> next;
}
prev在代碼中的任何位置聲明瞭哪裏? – GWW 2011-06-02 04:49:48
ahhh,非常感謝你 – 2011-06-02 05:16:42
回答編輯顯示prev的初始化。 – user209051 2011-06-02 18:42:01