vc编译报错,但不知道原因,高手们来看下
#define LEN sizeof(struct node)
#define NULL 0;
#include "stdio.h"
#include "stdlib.h"
struct node
{
char data;
struct node *next;
};
struct node* creat_l(char * strCode, int n)
{
int i;
struct node *head = (struct node*)malloc(LEN);
struct node *tail = (struct node*)malloc(LEN);
for (i = 0; i < n-1; i++)
{
struct node *trial = (struct node*)malloc(LEN);
trial->data = strCode[i];
if (0 == i)
{
head->next = trial;
tail = head->next;
}
else
tail->next = trial;
tail = trial;
if (i == n-2)
trial->next = NULL;
}
return (head);
}
void print_l(struct node *head)
{
while (head != NULL)
{
printf("%c\n", head->data);
head = head->next;
}
}
main()
{
int n = 14;
char strCode[] = "12345678abcde";
struct node *head = creat_l(strCode,n);
print_l(head);
}
while (head != NULL)
这句话老是报错,说
syntax error : missing ')' before ';'
syntax error : ')'
不明白啊...
问题点数:20、回复次数:2Top
1 楼xiaocai0001(高楼目尽欲黄昏/梧桐叶上萧萧雨)回复于 2005-11-01 18:58:48 得分 20
#define NULL 0;
------------------
宏定义后面不需要加分号的
#define NULL 0
就可以了
不过一般来说NULL不需要宏定义的
stdio.h
与
iostream.h
头文件都有宏定义过了
Top
2 楼tutuniu(土土牛)回复于 2005-11-01 19:37:58 得分 0
ok,非常感谢Top




