ヒープから印刷しようとしています。NULL ポインターに遭遇した場合は、NULL を出力する必要があります。それ以外の場合は、その値を出力します。
出力例:
1 [2]
2 null
3 null
4 [7, 3]
5 null
6 [7]
しかし、私のコードは NULL ポインターを逆参照するためにクラッシュし続けます。
テスト用に書いたコードは次のとおりです。
void printResult(IntList* intL, int nNode, int nEdge)
{
int i;
for (i; i <= 10; i++)
{
if (intRest((intL))
{
printf("%d", intFirst((intL)[i]));
intRest((intL)[i]);
}
else
printf(" NULL ");
}
}
//Here is the definition of functions:
//First
int intFirst(IntList oldL)
{
return oldL->element;
}
/** rest
*/
IntList intRest(IntList oldL)
{
return oldL->next;
}
//=================
struct IntListNode
{
int element;
IntList next;
};
//===================
typedef struct IntListNode * IntList;