我正在尝试打印一个 char* 的链表的内容,但是 while 循环弄乱了代码:
获取链表中下一项的函数:
char * list_next(list *l)
{
list *currentPosition = NULL;
currentPosition = l->next; //since the first node is a dummy value in the singly linked list
while (currentPosition != NULL)
{
return currentPosition->charValue;
currentPosition = currentPosition->next;
}
return NULL;
}
在我的主要:
char * item;
while(item = list_next(list))
printf("%s ",item);
有人可以帮我吗我很确定问题是while循环内的返回但我似乎无法修复它