出现这个问题怎么回事啊C:\pro\pro.cpp(29) : error C2440: '=' : cannot convert from 60
代码如下:#include<stdio.h>#include<stdlib.h>#defineSeqListstructlisttype#defineMaxSize100...
代码如下:#include<stdio.h>
#include<stdlib.h>
#define SeqList struct listtype
#define MaxSize 1000
SeqList
{
int data[MaxSize];
int last;
}seq;
void fuzhi(SeqList *L)
{
int a;
printf("input number,'0' will exit\n");
scanf("%d",&a);
while((a!=0)&&(L->last<999))
{
L->last++;
if(a!=0)
L->data[L->last] = a;
scanf("%d",&a);
}
}
void main()
{ int i,j;
SeqList *a,*b,*c;
a = malloc(sizeof(SeqList));
a->last = -1;
b = malloc(sizeof(SeqList));
b->last = -1;
c = malloc(sizeof(SeqList));
c->last = -1;
fuzhi(a);printf("OK\n");
fuzhi(b);printf("OK\n");
for(i=0;i<=a->last;i++)
{
c->data[i]=a->data[i];
}
c->last = a->last;
for(i=0;i<=b->last;i++)
{
for(j=0;j<=c->last;j++)
{
if(b->data[i]==c->data[j])
break;
}
if(j>c->last) {c->last++;c->data[c->last]=b->data[i]; }
}
for(i=0;i<=c->last;i++)
{
printf("%d\t",c->data[i]);
}
printf("\n");
}
错误是:C:\pro\pro.cpp(29) : error C2440: '=' : cannot convert from 'void *' to 'struct listtype *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
C:\pro\pro.cpp(31) : error C2440: '=' : cannot convert from 'void *' to 'struct listtype *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast 展开
#include<stdlib.h>
#define SeqList struct listtype
#define MaxSize 1000
SeqList
{
int data[MaxSize];
int last;
}seq;
void fuzhi(SeqList *L)
{
int a;
printf("input number,'0' will exit\n");
scanf("%d",&a);
while((a!=0)&&(L->last<999))
{
L->last++;
if(a!=0)
L->data[L->last] = a;
scanf("%d",&a);
}
}
void main()
{ int i,j;
SeqList *a,*b,*c;
a = malloc(sizeof(SeqList));
a->last = -1;
b = malloc(sizeof(SeqList));
b->last = -1;
c = malloc(sizeof(SeqList));
c->last = -1;
fuzhi(a);printf("OK\n");
fuzhi(b);printf("OK\n");
for(i=0;i<=a->last;i++)
{
c->data[i]=a->data[i];
}
c->last = a->last;
for(i=0;i<=b->last;i++)
{
for(j=0;j<=c->last;j++)
{
if(b->data[i]==c->data[j])
break;
}
if(j>c->last) {c->last++;c->data[c->last]=b->data[i]; }
}
for(i=0;i<=c->last;i++)
{
printf("%d\t",c->data[i]);
}
printf("\n");
}
错误是:C:\pro\pro.cpp(29) : error C2440: '=' : cannot convert from 'void *' to 'struct listtype *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast
C:\pro\pro.cpp(31) : error C2440: '=' : cannot convert from 'void *' to 'struct listtype *'
Conversion from 'void*' to pointer to non-'void' requires an explicit cast 展开
1个回答
展开全部
这样写就可以了:#includestructworder{char*name;char*no;intyear;intmenoy;};intmain(){structwordera1={"liming","441224198612213421",6,3500};printf("\tname\tno\tyear\tmenoy\t");printf("\n");printf("\t%2s\t%2s\t%d\t%d\t",a1.name,a1.no,a1.year,a1.menoy);printf("\n");return0;}自己读一下吧。
追问
这是什么呀 根本没关系好嘛
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询