表达式必须是可修改的左值
程序代码:
#include <stdio.h> #include<stdlib.h> struct Node { char name[32]; Node * next; }; void printz(Node * pHead) { while (pHead) { printf("%s ", pHead->name); pHead = pHead->next; } } Node * DelLast(Node * pHead) { Node * pTemp = pHead; if (pHead->next == NULL) { printf("只剩下一个头节点:%s\n", pTemp->name); free(pTemp); return NULL; } else { while (pTemp->next->next == NULL) { pTemp = pTemp->next; } printf("找到倒数第二个节点: %s\n", pTemp->name); free(pTemp->next); pTemp->next = NULL; return pTemp; } } int main() { Node student[5] = { {"abc",&student[1]}, {"bcd",&student[2]}, {"cde",&student[3]}, {"def",&student[4]}, {"efg",NULL} }; printz(student); student = DelLast(student); getchar(); return 0; }
第49行 表达式必须是可修改的左值 我返回结构体 为什么不行??