请检查 [英] please check
问题描述
我已为单个链表编写代码...我收到错误
表达式语法在标有////////的行中。请纠正我
我哪里错了。我在TURBO编译器中对此进行了编译
#include< stdio.h>
#include< alloc.h>
struct node
{
int data;
struct node * link;
};
void main()
{
int num = 10;
struct node * p;
p = NULL ;
追加(& p,num);
getch();
}
struct node * firstnode(int num)
{
struct node * p;
p =(struct node *)malloc(sizeof(struct node));
p-> data = num;
p-> link = NULL;
返回p;
}
append(struct node ** q,int num)
{
struct node * temp,* r;
if(* q == NULL)
* q = firstnode(int); ////////////////////////////
其他
{
temp = * q;
while(temp-> link!= NULL)
temp = temp-> link;
r = malloc(sizeof(struct node));
r-> data = num;
r-> link = NULL;
temp-> link = r;
}
返回0;
}
I have written code for single linked list...I get an error as
Expression syntax in the line marked with ////////. Please correct me
where am I going wrong. I compiled this in TURBO Compiler
#include<stdio.h>
#include<alloc.h>
struct node
{
int data;
struct node *link;
};
void main()
{
int num=10;
struct node *p;
p=NULL;
append(&p,num);
getch();
}
struct node *firstnode(int num)
{
struct node *p;
p=(struct node*)malloc(sizeof(struct node));
p->data=num;
p->link=NULL;
return p;
}
append(struct node **q,int num)
{
struct node *temp,*r;
if(*q==NULL)
*q= firstnode(int); ////////////////////////////
else
{
temp=*q;
while(temp->link!=NULL)
temp=temp->link;
r=malloc(sizeof(struct node));
r->data=num;
r->link=NULL;
temp->link=r;
}
return 0;
}
推荐答案
On Mon,2006-10-16 at 06:59 -0700,raghu写道:
On Mon, 2006-10-16 at 06:59 -0700, raghu wrote:
我有为单链表编写代码...我收到错误
表达式语法在标有////////的行中。请纠正我
我哪里错了。我在TURBO编译器中对此进行了编译
#include< stdio.h>
#include< alloc.h>
struct node
{
int data;
struct node * link;
};
I have written code for single linked list...I get an error as
Expression syntax in the line marked with ////////. Please correct me
where am I going wrong. I compiled this in TURBO Compiler
#include<stdio.h>
#include<alloc.h>
struct node
{
int data;
struct node *link;
};
< snipped similar>
你能格式化并再试一次吗?从我看到的,你的代码有/很多/
问题,但我希望能够阅读它。
没有< alloc.h>这样的东西。
-
Andrew Poelstra< http://www.wpsoftware。 net / projects />
<snipped similar>
Could you format and try again? From what I saw, there''s a /lot/ of
problems with your code, but I''d like to be able to read it.
There''s no such thing as <alloc.h>.
--
Andrew Poelstra <http://www.wpsoftware.net/projects/>
raghu写道:
raghu wrote:
我已编写单个代码链表...我得到一个错误
表达式语法在标有////////的行中。请纠正我
我哪里错了。我在TURBO编译器中对此进行了编译
#include< stdio.h>
#include< alloc.h>
struct node
{
int data;
struct node * link;
};
void main()
{
int num = 10;
struct node * p;
p = NULL ;
追加(& p,num);
getch();
}
struct node * firstnode(int num)
{
struct node * p;
p =(struct node *)malloc(sizeof(struct node));
p-> data = num;
p-> link = NULL;
返回p;
}
append(struct node ** q,int num)
{
struct node * temp,* r;
if(* q == NULL)
* q = firstnode(int); ////////////////////////////
其他
{
temp = * q;
while(temp-> link!= NULL)
temp = temp-> link;
r = malloc(sizeof(struct node));
r-> data = num;
r-> link = NULL;
temp-> link = r;
}
返回0;
}
I have written code for single linked list...I get an error as
Expression syntax in the line marked with ////////. Please correct me
where am I going wrong. I compiled this in TURBO Compiler
#include<stdio.h>
#include<alloc.h>
struct node
{
int data;
struct node *link;
};
void main()
{
int num=10;
struct node *p;
p=NULL;
append(&p,num);
getch();
}
struct node *firstnode(int num)
{
struct node *p;
p=(struct node*)malloc(sizeof(struct node));
p->data=num;
p->link=NULL;
return p;
}
append(struct node **q,int num)
{
struct node *temp,*r;
if(*q==NULL)
*q= firstnode(int); ////////////////////////////
else
{
temp=*q;
while(temp->link!=NULL)
temp=temp->link;
r=malloc(sizeof(struct node));
r->data=num;
r->link=NULL;
temp->link=r;
}
return 0;
}
这是我给comp.lang.c发的第一篇文章,所以对你们所有人都好。
你用无效参数调用firstnode函数 - ''int''。尝试将
置于真实的int参数 - 变量或常量,可能是''num''即
append()函数的参数。您现在可以发送类型int
这是不允许的。
This is my first post to comp.lang.c, so hello to all there.
You call firstnode function with invalid parameter - ''int''. Try to
place real int parameter- variable or constant, may be ''num'' that is
parameter of append() function. You now are triyng to send the type int
which is not allowed.
Andrew Poelstra< ap **** ***@false.sitewrites:
Andrew Poelstra <ap*******@false.sitewrites:
On Mon,2006-10-16 at 06:59 -0700,raghu写道:
On Mon, 2006-10-16 at 06:59 -0700, raghu wrote:
>我已为单个链表编写代码...我在////////标有行的表达式语法中出现错误。请纠正我
我哪里错了。我在TURBO编译器中编译了它
#include< stdio.h>
#include< alloc.h>
struct node
{
int data;
struct node * link;
};
>I have written code for single linked list...I get an error as
Expression syntax in the line marked with ////////. Please correct me
where am I going wrong. I compiled this in TURBO Compiler
#include<stdio.h>
#include<alloc.h>
struct node
{
int data;
struct node *link;
};
< snipped similar>
你能格式化并再试一次吗?从我看到的,你的代码有/很多/
问题,但我希望能够阅读它。
没有< alloc.h>这样的东西。
<snipped similar>
Could you format and try again? From what I saw, there''s a /lot/ of
problems with your code, but I''d like to be able to read it.
There''s no such thing as <alloc.h>.
是的。它可能不是ISO标准,但肯定是在那里
alloc.h实现。
到OP:
在append fnuction中查看对firstnode的调用。为什么你
传递" int"而不是数字?
Yes there is. It might not be ISO standard, but there sure as hell are
alloc.h implementations out there.
To the OP :
Check out your call to firstnode in the append fnuction. Why are you
passing "int" as opposed to a number?
这篇关于请检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!