errror C 2061 语法错误:标识符‘’Nodeptr‘’
TIAWE 2018-09-20 09:32:53 #include <stdio.h>
#include <stdlib.h>
int FindPrevious(int nun, NodePtr header);
struct ListNode {
int num;
struct ListNode *next;
};
typedef struct ListNode Node;
typedef Node *NodePtr;
int main() {
int n, i,a;
struct ListNode *head, *p;
printf("Please enter the number of data you want to input:");
scanf_s("%d", &n);
head = (struct ListNode*)malloc(sizeof(struct ListNode)); //Create the header node
p = (struct ListNode*)malloc(sizeof(struct ListNode)); //Create the first node
p = head->next;
printf("Please enter numbers you want to input:\n");
for (i = 0; i < n; i++) {
scanf_s("%d", &p->num);
p->next = (struct ListNode*)malloc(sizeof(struct ListNode));
p = p->next;
}
p = head->next;
NodePtr xNode=head;
printf("Please input the node value :\n");
scanf_s("%d", &a);
FindPrevious(a, xNode);
getchar();
}
int FindPrevious(int number, NodePtr header) {
NodePtr p;
p = header;
while (p->next&&p->next->num != number) {
p = p->next;
}
if (p->next) {
printf("The previous Node of %d is %d\n", number, p->num);
}
else {
printf("There is no data there!\n");
}
}