error: syntax error before '{' token不知道怎么改
这是我的代码#include"stdio.h"intmain(){structdate{intyear;intmonth;intday;};structsong{char...
这是我的代码
#include"stdio.h"
int main()
{
struct date
{
int year;
int month;
int day;
};
struct song
{
char title[64];
char artist[37];
int time;
struct date published;
};
struct song song1={"红豆","王菲",180,{2013,03,20}};
printf={"song1所有信息:歌名:%s\n 歌手%s\n 播放时间%s\n 出版时间%d年%d月%d日\n",song1.title,song1.artist,song1.time,
song1.published.year,song1.published.month,song1.published.day};
return 0;
}
求助~ 展开
#include"stdio.h"
int main()
{
struct date
{
int year;
int month;
int day;
};
struct song
{
char title[64];
char artist[37];
int time;
struct date published;
};
struct song song1={"红豆","王菲",180,{2013,03,20}};
printf={"song1所有信息:歌名:%s\n 歌手%s\n 播放时间%s\n 出版时间%d年%d月%d日\n",song1.title,song1.artist,song1.time,
song1.published.year,song1.published.month,song1.published.day};
return 0;
}
求助~ 展开
2个回答
展开全部
你又好几个问题呢,一是printf后不能加=号,二不能使用大括号要使用小括号,三打出播放时间你用的不能是%s要用%d因为时间是整型,修改后程序如下
#include"stdio.h"
int main()
{
struct date
{
int year;
int month;
int day;
};
struct song
{
char title[64];
char artist[37];
int time;
struct date published;
};
struct song song1={"红豆","王菲",180,{2013,03,20}};
printf("song1所有信息:歌名:%s\n 歌手%s\n 播放时间%d\n 出版时间%d年%d月%d日\n",song1.title,song1.artist
,song1.time,song1.published.year,song1.published.month,song1.published.day);
return 0;
}
#include"stdio.h"
int main()
{
struct date
{
int year;
int month;
int day;
};
struct song
{
char title[64];
char artist[37];
int time;
struct date published;
};
struct song song1={"红豆","王菲",180,{2013,03,20}};
printf("song1所有信息:歌名:%s\n 歌手%s\n 播放时间%d\n 出版时间%d年%d月%d日\n",song1.title,song1.artist
,song1.time,song1.published.year,song1.published.month,song1.published.day);
return 0;
}
追问
太谢谢了,正常运行了
展开全部
大括号前有语法错误printf();
更多追问追答
追问
改成()以后又报新的错了
就是printf的下一行
error: invalid lvalue in assignment|
追答
printf("song1所有信息:歌名:%s\n 歌手%s\n 播放时间%s\n 出版时间%d年%d月%d日\n",song1.title,song1.artist,song1.time,
song1.published.year,song1.published.month,song1.published.day);
应该是参数类型不兼容
也就是%s对应的要是兼容的类型
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询