Microsoft Visual C++ V6.0出现:fatal error C1021: invalid preprocessor command 'difine'
#include<stdio.h>#include<malloc.h>#difineNULL0#difineLENsizcof(structnumber)structnu...
# include<stdio.h >
# include <malloc.h>
#difine NULL 0
#difine LEN sizcof(struct number)
struct number
{int num ;
struct number *next;
};
int n;
struct number *creat(void)
{ struct number *head;
struct number *p1,*p2;
n=0:
p1=p2= (struct number*)malloc(LEN);
scanf("%d",&p1->num);
head=NULL;
while (p1->num!=0)
{n=n+1;
If(n= =0)head=p1;
else p2->next=p1;
p2=p1;
p1= (struct number *)malloc(LEN);
scanf("%d",&p1->num);
}
p2->next=NULL;
return (head);
}
void Print(struct number *head)
{struct number *p;
printf ("\nNow, These %d records are :\n",n);
p=head;
if (head!=NULL)
do
{printf ("%d ",p->num);
p=p->next;
}while (p!=NULL);
}
struct number*Remove(struct number *head,int num)
if(head==NULL) {printf ("\nlist null! \n");goto end;
return;}
p1=head;
while(num!=p1->num &&p1->next!==NULL)
{p1=p2;p1=p1->next;}
if(num= =p1->num)
{if(p1==head)head=p1->next;
else p2->next =p1->next;
printf("remove:% d\n",num);
}
else printf("%d not been found !\n", num );
return(head);
}
int length(struct number*head)
{int i=0;
struct number*p;
p=head;
while(p!=NULL)
{p=p->next;i++;
}
return i;
}
struct number *Insert (struct number*head, struct number *stud)
{struct number *p0,*p1,*p2;
p1=head;
p0=stud;
if (head= =NULL)
{head=p0;p0->next=NULL;}
else
scanf("%d,%d",n,count);
while ( n>=0 && n < length(head) )
{p2=p1;
p1=p1->next;
n=n+1;
}
if (n=length(head)) p1->next=p0;p0->next=NULL;
return (head);
}
运行以后:
--------------------Configuration: danxinglian - Win32 Debug--------------------
Compiling...
lianbiao.c
c:\documents and settings\atiya\桌面\visual c++\myprojects\danxinglian\lianbiao.c(3) : fatal error C1021: invalid preprocessor command 'difine'
执行 cl.exe 时出错.
danxinglian.exe - 1 error(s), 0 warning(s)
怎么改程序才能正常运行啊???
万分感谢!
define 改过来以后错误还是很多~~~~ 展开
# include <malloc.h>
#difine NULL 0
#difine LEN sizcof(struct number)
struct number
{int num ;
struct number *next;
};
int n;
struct number *creat(void)
{ struct number *head;
struct number *p1,*p2;
n=0:
p1=p2= (struct number*)malloc(LEN);
scanf("%d",&p1->num);
head=NULL;
while (p1->num!=0)
{n=n+1;
If(n= =0)head=p1;
else p2->next=p1;
p2=p1;
p1= (struct number *)malloc(LEN);
scanf("%d",&p1->num);
}
p2->next=NULL;
return (head);
}
void Print(struct number *head)
{struct number *p;
printf ("\nNow, These %d records are :\n",n);
p=head;
if (head!=NULL)
do
{printf ("%d ",p->num);
p=p->next;
}while (p!=NULL);
}
struct number*Remove(struct number *head,int num)
if(head==NULL) {printf ("\nlist null! \n");goto end;
return;}
p1=head;
while(num!=p1->num &&p1->next!==NULL)
{p1=p2;p1=p1->next;}
if(num= =p1->num)
{if(p1==head)head=p1->next;
else p2->next =p1->next;
printf("remove:% d\n",num);
}
else printf("%d not been found !\n", num );
return(head);
}
int length(struct number*head)
{int i=0;
struct number*p;
p=head;
while(p!=NULL)
{p=p->next;i++;
}
return i;
}
struct number *Insert (struct number*head, struct number *stud)
{struct number *p0,*p1,*p2;
p1=head;
p0=stud;
if (head= =NULL)
{head=p0;p0->next=NULL;}
else
scanf("%d,%d",n,count);
while ( n>=0 && n < length(head) )
{p2=p1;
p1=p1->next;
n=n+1;
}
if (n=length(head)) p1->next=p0;p0->next=NULL;
return (head);
}
运行以后:
--------------------Configuration: danxinglian - Win32 Debug--------------------
Compiling...
lianbiao.c
c:\documents and settings\atiya\桌面\visual c++\myprojects\danxinglian\lianbiao.c(3) : fatal error C1021: invalid preprocessor command 'difine'
执行 cl.exe 时出错.
danxinglian.exe - 1 error(s), 0 warning(s)
怎么改程序才能正常运行啊???
万分感谢!
define 改过来以后错误还是很多~~~~ 展开
4个回答
展开全部
很多错
不下10个
----------------------------------------------------------------
改后
# include<stdio.h >
# include <malloc.h>
#define NULL 0
#define LEN sizeof(struct number)
struct number
{int num ;
struct number *next;
};
int n;
struct number *creat(void)
{ struct number *head;
struct number *p1,*p2;
n=0;
p1=p2= (struct number*)malloc(LEN);
scanf("%d",&p1->num);
head=NULL;
while (p1->num!=0)
{n=n+1;
if(n==0)head=p1;
else p2->next=p1;
p2=p1;
p1= (struct number *)malloc(LEN);
scanf("%d",&p1->num);
}
p2->next=NULL;
return (head);
}
void Print(struct number *head)
{struct number *p;
printf ("\nNow, These %d records are :\n",n);
p=head;
if (head!=NULL)
do
{printf ("%d ",p->num);
p=p->next;
}while (p!=NULL);
}
struct number *Remove(struct number *head,int num)
{
if(head==NULL)
{
printf ("\nlist null! \n");
//goto end;
return 0;
}
else
{
struct number *p1;
struct number *p2;
p1=head;
while(num!=p1->num&&p1->next!=NULL)
{
p1=p2;p1=p1->next;
}
if(num==p1->num)
{if(p1==head) head=p1->next;
else p2->next=p1->next;
printf("remove:% d\n",num);
}
else printf("%d not been found !\n", num );
}
return (head);
}
int length(struct number*head)
{int i=0;
struct number*p;
p=head;
while(p!=NULL)
{p=p->next;i++;
}
return i;
}
struct number *Insert (struct number*head, struct number *stud)
{struct number *p0,*p1,*p2;
p1=head;
p0=stud;
int count;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
scanf("%d,%d",n,count);
while ( n>=0 && n < length(head) )
{p2=p1;
p1=p1->next;
n=n+1;
}
if (n=length(head)) p1->next=p0;p0->next=NULL;
return (head);
}
运行,无错
由于end在哪儿,我不清楚,所以我把goto语句删除了。
不下10个
----------------------------------------------------------------
改后
# include<stdio.h >
# include <malloc.h>
#define NULL 0
#define LEN sizeof(struct number)
struct number
{int num ;
struct number *next;
};
int n;
struct number *creat(void)
{ struct number *head;
struct number *p1,*p2;
n=0;
p1=p2= (struct number*)malloc(LEN);
scanf("%d",&p1->num);
head=NULL;
while (p1->num!=0)
{n=n+1;
if(n==0)head=p1;
else p2->next=p1;
p2=p1;
p1= (struct number *)malloc(LEN);
scanf("%d",&p1->num);
}
p2->next=NULL;
return (head);
}
void Print(struct number *head)
{struct number *p;
printf ("\nNow, These %d records are :\n",n);
p=head;
if (head!=NULL)
do
{printf ("%d ",p->num);
p=p->next;
}while (p!=NULL);
}
struct number *Remove(struct number *head,int num)
{
if(head==NULL)
{
printf ("\nlist null! \n");
//goto end;
return 0;
}
else
{
struct number *p1;
struct number *p2;
p1=head;
while(num!=p1->num&&p1->next!=NULL)
{
p1=p2;p1=p1->next;
}
if(num==p1->num)
{if(p1==head) head=p1->next;
else p2->next=p1->next;
printf("remove:% d\n",num);
}
else printf("%d not been found !\n", num );
}
return (head);
}
int length(struct number*head)
{int i=0;
struct number*p;
p=head;
while(p!=NULL)
{p=p->next;i++;
}
return i;
}
struct number *Insert (struct number*head, struct number *stud)
{struct number *p0,*p1,*p2;
p1=head;
p0=stud;
int count;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
scanf("%d,%d",n,count);
while ( n>=0 && n < length(head) )
{p2=p1;
p1=p1->next;
n=n+1;
}
if (n=length(head)) p1->next=p0;p0->next=NULL;
return (head);
}
运行,无错
由于end在哪儿,我不清楚,所以我把goto语句删除了。
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Fatal Error C1021
invalid preprocessor command 'string'
The characters following the number sign (#) did not form a valid preprocessor directive.
The number sign cannot be used as the first character in an identifier.
msdn中给出的
invalid preprocessor command 'string'
The characters following the number sign (#) did not form a valid preprocessor directive.
The number sign cannot be used as the first character in an identifier.
msdn中给出的
参考资料: msdn
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
写错了 是#define
二楼的 华信333 正解!
二楼的 华信333 正解!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
只是define你写成了difine
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询