0

これが私のコードです:

void printlist(struct node *st) { 
  while(st != NULL); {
    printnode(st);
    st=st->next;
  }
  return;
}

ただし、プログラムを実行するparse error before;
とエラーが発生します。エラーの場所がわかりません。

4

2 に答える 2

4

これ:

while(st != NULL); {

これである必要があります:

while(st != NULL) {

セミコロンが問題です。

于 2013-03-12T21:21:58.620 に答える
3
  while(st != NULL); {
    printnode(st);
    st=st->next;
  }

あなたが思っていることを実際にはしません。フォーマットさせてください

  while (st != NULL) ;

  {
    printnode(st);
    st=st->next;
  }

つまり、st が null でない間は何もせず、次のブロックを無条件に実行します。

于 2013-03-12T21:23:18.450 に答える