在c语言中、出现error C2440: 'initializing' : cannot convert from 'char [2]' to 'int'
我做的作业:#include<stdio.h>structworder{charname[20];charno[19];intyear;intmenoy;};intmai...
我做的作业:
#include<stdio.h>
struct worder
{
char name[20];
char no[19];
int year;
int menoy;
};
int main()
{
struct worder a1={"li ming","441224198612213421","6","3500"};
printf("\tname\tno\tyear\tmenoy\t");
prittf("\t%2c%2d%d\t%d\t",a1.name,a1.no,a1.year,a1.menoy);
return 0;
}帮我看看吧。谢谢! 展开
#include<stdio.h>
struct worder
{
char name[20];
char no[19];
int year;
int menoy;
};
int main()
{
struct worder a1={"li ming","441224198612213421","6","3500"};
printf("\tname\tno\tyear\tmenoy\t");
prittf("\t%2c%2d%d\t%d\t",a1.name,a1.no,a1.year,a1.menoy);
return 0;
}帮我看看吧。谢谢! 展开
3个回答
推荐于2017-09-30
展开全部
这样写就可以了:
#include<stdio.h>
struct worder
{
char * name;
char * no;
int year;
int menoy;
};
int main()
{
struct worder a1={"li ming","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");
return 0;
}
自己读一下吧。
#include<stdio.h>
struct worder
{
char * name;
char * no;
int year;
int menoy;
};
int main()
{
struct worder a1={"li ming","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");
return 0;
}
自己读一下吧。
展开全部
struct worder a1={"li ming","441224198612213421",6,3500};后面的2个不需要带引号的。
这个错误翻译过来就是不能将字符串赋值给int型变量。
这个错误翻译过来就是不能将字符串赋值给int型变量。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不能将字符串赋值给int型变量。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询