鱼C论坛

 找回密码
 立即注册
查看: 749|回复: 1

[已解决]代码报错

[复制链接]
发表于 2020-4-18 14:26:40 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
这段代码报错是什么原因
  1. Compiling...
  2. 1.cpp
  3. D:\VC++\Microsoft Visual Studio\MyProjects\3\1.cpp(34) : error C2039: 'birthbay' : is not a member of '__unnamed'
  4.         D:\VC++\Microsoft Visual Studio\MyProjects\3\1.cpp(13) : see declaration of '__unnamed'
  5. D:\VC++\Microsoft Visual Studio\MyProjects\3\1.cpp(34) : error C2228: left of '.month' must have class/struct/union type
  6. D:\VC++\Microsoft Visual Studio\MyProjects\3\1.cpp(35) : error C2039: 'birthbay' : is not a member of '__unnamed'
  7.         D:\VC++\Microsoft Visual Studio\MyProjects\3\1.cpp(13) : see declaration of '__unnamed'
  8. D:\VC++\Microsoft Visual Studio\MyProjects\3\1.cpp(35) : error C2228: left of '.month' must have class/struct/union type
  9. 执行 cl.exe 时出错.
复制代码
  1. #include <stdio.h>

  2. void main()
  3. {
  4.       struct date
  5.       {
  6.             int month;
  7.             int day;
  8.             int year;
  9.       };

  10.       struct
  11.       {
  12.             int num;
  13.             char name[20];
  14.             char sex;
  15.             struct date birthday;
  16.             float score;
  17.       } boy1, boy2;
  18.       
  19.       printf("Please input birthday(YY;)");
  20.       scanf("%d", &boy1.birthday.year);

  21.       printf("Please input birthday(MM:)");
  22.       scanf("%d", &boy1.birthday.month);

  23.       printf("Please input birthday(DD;)");
  24.       scanf("%d", &boy1.birthday.day);

  25.       printf("\n");

  26.       boy2 = boy1;

  27.       printf("boy1's birthday is %d-%d-%d\n", boy1.birthday.year, boy1.birthbay.month, boy1.birthday.day);
  28.       printf("boy1's birthday is %d-%d-%d\n", boy2.birthday.year, boy2.birthbay.month, boy2.birthday.day);
  29. }
复制代码
最佳答案
2020-4-18 15:58:55
boy1.birthbay.month   改为  boy1.birthday.month

birthbay  这个单词拼错了
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-4-18 15:58:55 | 显示全部楼层    本楼为最佳答案   
boy1.birthbay.month   改为  boy1.birthday.month

birthbay  这个单词拼错了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-7 11:39

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表