警告 C6001 使用未初始化的内存“*head”。
#include
#include
#include
#include
using namespace std;
typedef struct list {
int number;
struct list* next;
}list;
void build(list* head,int n) {
list* p,* rear = head;
for (int i = 0; i < n; i++) {
list* p = new list;
cin >> p->number;
p = p->next;
rear = p;
}
rear->next = NULL;
}
int main() {
list* head = new list;
list* p = head->next;
int n,m,flag;
cin >> n;
build(head, n);
while (n > 0) {
cout << p->number;
p = p->next;
}
}
这个报错是为什么啊。。。。。想了好久想不明白。。。。。