c语言高手请进,坐等....
#include<stdio.h>#include<malloc.h>structnode{intnum;structnode*next;};voidmain(){str...
#include <stdio.h>
#include <malloc.h>
struct node
{int num;
struct node *next;};
void main()
{struct node *p,*q,*r;
p=(struct node*) malloc(sizeof(struct node));
q=(struct node*) malloc(sizeof(struct node));
r=(struct node*) malloc(sizeof(struct node));
p->num=10;
q->num=20;
r->num=30;
p->next=q;q->num=r;
printf("%d\n",p->num+q-q->next->num);
}
--------------------Configuration: 138_2 - Win32 Debug--------------------
Compiling...
138-2.cpp
C:\Documents and Settings\Administrator.A5685D3CF26642A\桌面\高福 20100847\138_2\138-2.cpp(14) : error C2440: '=' : cannot convert from 'struct node *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.
138_2.exe - 1 error(s), 0 warning(s) 展开
#include <malloc.h>
struct node
{int num;
struct node *next;};
void main()
{struct node *p,*q,*r;
p=(struct node*) malloc(sizeof(struct node));
q=(struct node*) malloc(sizeof(struct node));
r=(struct node*) malloc(sizeof(struct node));
p->num=10;
q->num=20;
r->num=30;
p->next=q;q->num=r;
printf("%d\n",p->num+q-q->next->num);
}
--------------------Configuration: 138_2 - Win32 Debug--------------------
Compiling...
138-2.cpp
C:\Documents and Settings\Administrator.A5685D3CF26642A\桌面\高福 20100847\138_2\138-2.cpp(14) : error C2440: '=' : cannot convert from 'struct node *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
执行 cl.exe 时出错.
138_2.exe - 1 error(s), 0 warning(s) 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询