これが私のコードです:
void printlist(struct node *st) {
while(st != NULL); {
printnode(st);
st=st->next;
}
return;
}
ただし、プログラムを実行するparse error before;
とエラーが発生します。エラーの場所がわかりません。
これ:
while(st != NULL); {
これである必要があります:
while(st != NULL) {
セミコロンが問題です。
while(st != NULL); {
printnode(st);
st=st->next;
}
あなたが思っていることを実際にはしません。フォーマットさせてください
while (st != NULL) ;
{
printnode(st);
st=st->next;
}
つまり、st が null でない間は何もせず、次のブロックを無条件に実行します。