gpt4 book ai didi

c - 获取ubuntu存储大小下的时间

转载 作者:行者123 更新时间:2023-11-30 15:26:29 25 4
gpt4 key购买 nike

我正在用C语言编写一个程序,它是Ubuntu 13.04环境下一个理发店一把椅子模型的模拟程序。

我有一个计时器()函数,它给了我这个错误:

“t”的存储大小未知>>

这是函数和调用它的指令:

  #include<time.h>
#include<math.h>
#include<stdlib.h>

功能:

 long timer()
{
//get current system time
struct time t;

gettime(&t);
//return number of hundred of second
return(((long)3600*t.ti_hour+60*t.ti_min+t.ti_sec)*100+t.ti_hund);
}

调用该函数的指令:

 srand((unsigned) timer());

可能的问题是:

1-主要错误是什么?

2-如何修复此错误?

最佳答案

您似乎正在尝试在 Linux 上运行 MS-DOS/Turbo-C 代码?

Unix C 库中没有 struct timegettime() 函数,您可能正在寻找 struct tmlocaltime() 相反,参见例如:

http://www.tutorialspoint.com/c_standard_library/c_function_localtime.htm

关于c - 获取ubuntu存储大小下的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27334142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com