获取 ubuntu 存储大小下的时间 [英] get the time under ubuntu storage size
问题描述
我正在用 C 语言编写一个程序,它是 Ubuntu 13.04 环境下一个理发店一张椅子模型的模拟程序.
I'm writing a program in C-language which its a simulation program for one barbershop one chair model under Ubuntu 13.04 environment .
我有一个 timer () 函数,它给了我这个错误:
I have a timer () function which gives me this error :
‘t’的存储大小未知>>
这是调用它的函数和指令:
here is the function and the instruction which call it :
#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- 主要错误是什么?
1- what that's error main ?
2-我该如何解决这个错误?
2-how can I fix this error ?
推荐答案
您似乎正在尝试在 Linux 上运行 MS-DOS/Turbo-C 代码?
You seem to be trying to run MS-DOS / Turbo-C code on Linux?
Unix C 库中没有 struct time
和 gettime()
函数,您可能正在寻找 struct tm
和 >localtime()
代替,参见例如:
There's no struct time
and gettime()
function in the Unix C library, you're probably looking for struct tm
and localtime()
instead, see e.g.:
http://www.tutorialspoint.com/c_standard_library/c_function_localtime.htm
这篇关于获取 ubuntu 存储大小下的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!