两种写法都莫得输出,求大神帮忙看看问题在哪?
两种写法不同的地方就是 Print() 这个函数的参量的传入方式。
#include<bits/stdc++.h>
using namespace std;
typedef struct node * Node;
struct node
{
int data;
Node next;
};
int Print(Node &h)
{
return h->data;
}
int main()
{
Node h = NULL;
h->data = 1;
h->next = NULL;
int t = Print(h);
printf("%d\n",t);
return 0;
}
------------------------**********************
这是第二种写法
#include<bits/stdc++.h>
using namespace std;
typedef struct node * Node;
struct node
{
int data;
Node next;
};
int Print(Node h)
{
return h->data;
}
int main()
{
Node h = NULL;
h->data = 1;
h->next = NULL;
int t = Print(h);
printf("%d\n",t);
return 0;
}