标题:时钟代码,执行后出现"undefined reference to 'gettime' ",求各位大神指点 ...
取消只看楼主
pxf
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2016-4-13
结帖率:80%
已结贴  问题点数:20 回复次数:1 
时钟代码,执行后出现"undefined reference to 'gettime' ",求各位大神指点
#include<stdio.h>
#include<math.h>
#include<dos.h>
#include<conio.h>
#include<windows.h>
#include<sys/time.h>
int main()
{
    struct time
    {
        unsigned char ti_min;
        unsigned char ti_hour;
        unsigned char ti_hund;
        unsigned char ti_sec;
    };
    struct time curtime;
    float th_hour,th_min,th_sec;
    do
    {
        printf("****************************************\n");
        printf("**This is a simple clock program      **\n");
        printf("**                                    **\n");
        printf("****************************************\n");
        printf("The currenr time is:\n");

        gettime(&curtime);
        if((float)curtime.ti_hour<=12)
        {
            printf("AM");
            if((float)curtime.ti_hour<10)
                printf("0");
            printf("%.0f:",(float)curtime.ti_hour);
        }
        else
        {
            printf("PM");
            if((float)curtime.ti_hour<10)
                printf("0");
            printf("%.0f:",(float)curtime.ti_hour);
        }
        if((float)curtime.ti_min<10)
            printf("0");
        printf("%.0f:",(float)curtime.ti_min);
        if((float)curtime.ti_sec<10)
            printf("0");
        printf("%.0f:",(float)curtime.ti_sec);
        Sleep(1000);
        system ("cls");
    }while (1);
}
搜索更多相关主题的帖子: undefined reference include simple 
2016-04-17 15:02
pxf
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2016-4-13
得分:0 
回复 2楼 alice_usnet
谢谢大神,可是时间输出不对,时间为16:33时,编译生成PM26:158:00,是不是算法不对
2016-04-17 16:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-463741-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019585 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved