相关疑难解决方法(0)

如何在C++中获取当前时间和日期?

有没有一种跨平台的方式来获取C++中的当前日期和时间?

c++ time cross-platform date

407
推荐指数
14
解决办法
107万
查看次数

获取C中的当前时间

我想得到我系统的当前时间.为此,我在C中使用以下代码:

time_t now;
struct tm *mytime = localtime(&now); 
if ( strftime(buffer, sizeof buffer, "%X", mytime) )
{
    printf("time1 = \"%s\"\n", buffer);
}
Run Code Online (Sandbox Code Playgroud)

问题是这段代码给出了一些随机时间.此外,随机时间每次都不同.我想要我系统的当前时间.

c time time-t localtime

89
推荐指数
6
解决办法
42万
查看次数

dos.h for Linux?

我有一个包含#include <dos.h>标题的C程序.它显示编译时错误.我知道dos.h头文件在Linux中无效.

dos.h在Linux中是否还有其他等效标头?

c linux header-files

5
推荐指数
2
解决办法
2万
查看次数

C程序打印当前时间

我正在学习C程序.当尝试运行代码时,我收到错误:[错误] ld返回1退出状态

   #include <stdio.h>
   #include <time.h>

    void main()
     {

       time_t t;
       time(&t);

       clrscr();

       printf("Today's date and time : %s",ctime(&t));
       getch();

      }
Run Code Online (Sandbox Code Playgroud)

谁能解释一下我在这里做错了什么?

我试过这段代码:

 int main()
   {

  printf("Today's date and time : %s \n", gettime());
  return 0;

   }

  char ** gettime() { 

   char * result;

    time_t current_time;
    current_time = time(NULL);
   result = ctime(&current_time);

     return &result; 

   }
Run Code Online (Sandbox Code Playgroud)

但仍然显示错误为:错误:被叫对象'1'不是current_time = time(NULL)中的函数; 线.代码有什么问题

c windows time

4
推荐指数
1
解决办法
2万
查看次数

我怎样才能计算我的C程序?

我查看旧线程但找不到我的问题的答案:

如何在C程序中计算函数体?

c time runtime

2
推荐指数
1
解决办法
7239
查看次数

标签 统计

c ×4

time ×4

c++ ×1

cross-platform ×1

date ×1

header-files ×1

linux ×1

localtime ×1

runtime ×1

time-t ×1

windows ×1