我希望你们中的一些编码天才可能会帮助像我这样的编码受损个体。我必须创建这个程序,在我之前创建的另一个程序上添加时间戳。现在,我正在尝试使用C++中的gettimeofday函数获取时间(我们正在Unix btw中执行此操作)。一些帮助使用结构,参考和gettimeofday函数
无论如何,我有一小段代码准备编译,除了我不断收到2个特定的错误。也许,如果有人可以帮助我在这方面也给我的代码看起来到目前为止那简直太好了一些建议......
#include <curses.h>
#include <sys/time.h>
#include <time.h>
ExpandedTime* localTime(struct timeval* tv, ExpandedTime* etime);
struct ExpandedTime
{
double et_usec;
double et_sec;
double et_min;
double et_hour;
};
int main()
{
struct timeval tv;
struct ExpandedTime etime;
gettimeofday(&tv, NULL);
localTime(tv, ExpandedTime);
}
ExpandedTime* localTime(struct timeval* tv, ExpandedTime* etime)
{
}
基本上现在我只是想正常使用gettimeofday的,以及将定义为tv的timeval结构和扩展的时间结构传递给实际的本地时间函数....但是第33行,我称为localtime函数给了我2个特定的错误。
- 本地时间并没有在这个范围中声明
- 预期主要表达之前“)”令牌
任何帮助将不胜感激......的expandedtime功能是假设接收gettimeofday的值存储在我认为包含的头文件之一的某个结构中。
哦非常感谢你。如果我可能会问,ExpandedTime只是我在开始时声明的一个函数... iirc这是在程序中设置函数的标准方式......为什么编译器无法识别它是什么? – PresidentRFresh 2013-03-13 01:01:17
@ user2163350我*希望*你的意思是说*“**本地时间**只是一个功能...”*(和+1,大卫。很好的答案。) – WhozCraig 2013-03-13 01:02:59
是的,我的道歉。 localTime – PresidentRFresh 2013-03-13 01:03:35