鱼C论坛

 找回密码
 立即注册
查看: 3224|回复: 3

结构数组无法编译通过,求问题所在

[复制链接]
发表于 2011-4-1 16:11:08 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 soldier 于 2011-5-7 11:40 编辑
  1. #include <stdio.h>
  2. struct time
  3. {
  4.                 int hour;
  5.         int minutes;
  6.         int seconds;
  7. };
  8. int main (void)
  9. {
  10.      struct time timeupdate (struct time now);
  11.      struct time testtimes[5] = {{11, 59, 59}, {12, 0, 0},{1, 29, 59}, {23, 59, 59}, {19, 12, 27}};
  12.        
  13.             int i;
  14.        
  15.         for (i = 0; i < 5; ++i)
  16.         {
  17.             printf ("time is %.2i:%.2i:%.2i", testtimes[i].hour, testtimes[i].minutes, testtimes[i].seconds);
  18.                 testtimes[i] = timeupdate (testtimes[i]);
  19.                 printf ("...one second later it's %.2i:%.2i:%.2i\n", testtimes[i].hour, testtimes[i].minutes, testtimes[i].seconds);
  20.         }
  21.         return 0;
  22. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-5-7 12:54:45 | 显示全部楼层
本帖最后由 风扫地 于 2011-5-7 12:55 编辑

struct time timeupdate (struct time now);

这是在申明一个函数吧。? 函数的原型在哪里啊?

汗。。怎么是4月1号的帖子//。。囧
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-5-7 13:26:15 | 显示全部楼层
struct time timeupdate (struct time now);// 这是个是个函数吧?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2011-5-7 16:38:55 | 显示全部楼层
本帖最后由 soldier 于 2011-5-9 16:12 编辑
  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;

  4. struct time
  5. {
  6.        int hour;
  7.        int minutes;
  8.        int seconds;
  9. };

  10. struct time timeupdate ( struct time nows )
  11. {
  12.    
  13.     ++nows.seconds;
  14.     if ( nows.seconds == 60 )
  15.         {
  16.           nows.seconds = 0;
  17.           ++nows.minutes;
  18.         }
  19.    
  20.     if ( nows.minutes == 60)
  21.         {
  22.         nows.minutes = 0;
  23.         ++nows.hour;
  24.         }
  25.         if ( nows.hour == 24 )
  26.         {
  27.             nows.hour = 0;
  28.         }
  29.     return nows;
  30. }

  31. int main (void)
  32. {
  33.      struct time timeupdate(struct time now);
  34.    
  35.      struct time testtimes[5] = { {11, 59, 59},
  36.                                   {12, 0,  0 },
  37.                                   {1,  29, 59},
  38.                                   {23, 59, 59},
  39.                                   {19, 12, 27}
  40.                                 };
  41.       
  42.      int i;
  43.         
  44.     for (i = 0; i < 5; ++i)
  45.     {
  46.         printf ("time is %.2i:%.2i:%.2i",
  47.                  testtimes[i].hour,
  48.                  testtimes[i].minutes,
  49.                  testtimes[i].seconds
  50.                );
  51.         testtimes[i] = timeupdate (testtimes[i]);
  52.         printf ("...one second later it's %.2i:%.2i:%.2i\n",
  53.                 testtimes[i].hour,
  54.                 testtimes[i].minutes,
  55.                 testtimes[i].seconds
  56.                );
  57.     }
  58.   
  59.     system("pause");
  60.     return 0;
  61. }
复制代码
//不知道楼主要的是不是这个意思
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-3-29 15:00

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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