为什么print语句返回null?C中的值返回null,不知道为什么
#include <stdio.h>>
#include <stdlib.h>
struct Node
{
char abbreviation;
double number;
struct Node *next;
};
void insert(char abbreviation, double number, struct Node *head) {
struct Node *current = head;
while(current->next != NULL)
{
current = current->next;
}
struct Node *ptr = (struct Node*)malloc(sizeof(struct Node));
ptr->abbreviation = abbreviation;
ptr->number = number;
current->next = ptr;
return;
}
int main(int argc, char* argv[]) {
struct Node *head = (struct Node*)malloc(sizeof(struct Node));
insert('n',456,head);
printf("%s\n", head->abbreviation);
}
尝试使用'%C',而不是'%s' – nabroyan 2013-03-21 03:59:15
如果你的问题是关于C,请不要加'[C++]'标签。 – 2013-03-21 03:59:58
而且,由于C++代码消失了,不投中C. – 2013-03-21 04:00:32