请教,程序员考试的一道C语言问题
来源:百度知道 编辑:UC知道 时间:2024/07/02 16:15:29
错误提示如下:
error C2601: 'main' : local function definitions are illegal
fatal error C1004: unexpected end of file found
Error executing cl.exe.
ex01.exe - 2 error(s), 0 warning(s)
源代码如下,请指教啊,谢谢了!
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
int code;
struct node *next;
}NODE,*LinkList;
LinkList create_list(int n)
{
LinkList head,p;
int i;
head=(NODE *)malloc(sizeof(NODE));
if(!head)
{
printf("memory allocation error!\n");
return NULL;
}
head->code=1;head->next=head;
for(i=n;i>1;--i)
{
p=(NODE *)malloc(sizeof(NODE));
if(!p)
{
printf("memory allocation error!\n");
exit(1);
}
p->code=i;p->next=head->next;head->next=p;
}
return head;
}
void output(LinkLi
error C2601: 'main' : local function definitions are illegal
fatal error C1004: unexpected end of file found
Error executing cl.exe.
ex01.exe - 2 error(s), 0 warning(s)
源代码如下,请指教啊,谢谢了!
#include<stdio.h>
#include<stdlib.h>
typedef struct node{
int code;
struct node *next;
}NODE,*LinkList;
LinkList create_list(int n)
{
LinkList head,p;
int i;
head=(NODE *)malloc(sizeof(NODE));
if(!head)
{
printf("memory allocation error!\n");
return NULL;
}
head->code=1;head->next=head;
for(i=n;i>1;--i)
{
p=(NODE *)malloc(sizeof(NODE));
if(!p)
{
printf("memory allocation error!\n");
exit(1);
}
p->code=i;p->next=head->next;head->next=p;
}
return head;
}
void output(LinkLi
楼主,写代码应该注意缩进,像这种漏大括号的问题,便可以很容易发现了。
#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int code;
struct node *next;
}NODE,*LinkList;
LinkList create_list(int n)
{
LinkList head,p;
int i;
head=(NODE *)malloc(sizeof(NODE));
if(!head)
{
printf("memory allocation error!\n");
return NULL;
}
head->code=1;head->next=head;
for(i=n;i>1;--i)
{
p=(NODE *)malloc(sizeof(NODE));
if(!p)
{
printf("memory allocation error!\n");
exit(1);
}
p->code=i;p->next=head->next;head->next=p;
}
return head;
}
void output(LinkList head)
{
LinkList p;
p=head;
do{
printf("%4d",p->code);p=p->next;
}while(p!=head);
printf("\n");
}
void p