C语言将结构体中的一个成员复制到一个数组中,为什么不能print出来?
}Stu;structStudentInfoStuInfo[5]={{"1","求速度v","s/t"},{"2","求重力F","m*g"},{"3","求相对论能量E...
}Stu;
struct StudentInfo StuInfo[5]=
{
{"1","求速度v", "s/t"},
{"2","求重力F", "m*g"},
{"3","求相对论能量E","m*c*c"},
{"4","求万有引力G","G*(a+b)/r"},
{"5","求静电力F' ", "a*b/(20.121*r*r)"},
};
main( )
{
char s;
strcpy(&s,StuInfo[2].name);
printf("%s",s);
return 0;
} 展开
struct StudentInfo StuInfo[5]=
{
{"1","求速度v", "s/t"},
{"2","求重力F", "m*g"},
{"3","求相对论能量E","m*c*c"},
{"4","求万有引力G","G*(a+b)/r"},
{"5","求静电力F' ", "a*b/(20.121*r*r)"},
};
main( )
{
char s;
strcpy(&s,StuInfo[2].name);
printf("%s",s);
return 0;
} 展开
2个回答
展开全部
s的类型错了 你声明的char s是一个字符 应该声明一个指针才对char *s
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询