相关疑难解决方法(0)

什么原始数据类型是time_t?

我不知道数据类型time_t.它是浮动双重还是其他什么?因为如果我想显示它,我需要与之对应的标签printf.我可以从那里处理其余部分进行显示,time_t但我需要知道与之对应的数据类型.

c printf types time-t

46
推荐指数
3
解决办法
10万
查看次数

在C++中是否存在大于long long int的类型?

在C++中是否存在大于long long int的类型?

我的编译器是g ++.

c++ types

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

如何使用printf显示off_t,nlink_t,size_t和其他特殊类型?

在我的程序中,我统计他们想要的文件并发送数据.stat的字段struct都是特殊类型:

struct stat {
  dev_t     st_dev;     /* ID of device containing file */
  ino_t     st_ino;     /* inode number */
  mode_t    st_mode;    /* protection */
  nlink_t   st_nlink;   /* number of hard links */
  uid_t     st_uid;     /* user ID of owner */
  gid_t     st_gid;     /* group ID of owner */
  dev_t     st_rdev;    /* device ID (if special file) */
  off_t     st_size;    /* total size, in bytes */
  blksize_t st_blksize; /* blocksize for file system I/O */
  blkcnt_t  st_blocks;  /* number …
Run Code Online (Sandbox Code Playgroud)

c linux printf portability

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

实现定义类型的格式说明符,如time_t

我想让我的代码更加平台/实现独立.time_t在编译代码时,我不知道将在平台上实现什么.我如何知道t要确定使用哪种格式说明符的类型?

...
time_t t = time(NULL);
printf("%s", t);
...
Run Code Online (Sandbox Code Playgroud)

c printf typedef time-t

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

如何打印像ino_t这样的未知大小的类型?

我经常会遇到我想要printf使用整数类型的实现定义大小(如ino_t或time_t)的值进行打印的情况.现在,我使用这样的模式:

#include <inttypes.h>

ino_t ino; /* variable of unknown size */
printf("%" PRIuMAX, (uintmax_t)ino);
Run Code Online (Sandbox Code Playgroud)

这种方法到目前为止有效,但它有一些缺点:

  • 我必须知道我正在尝试打印的类型是签名还是未签名.
  • 我必须使用可能会扩大我的代码的类型转换.

有更好的策略吗?

c printf portability

23
推荐指数
3
解决办法
7785
查看次数

Microsoft Visual Studio 2010是否支持c99?

我想知道Microsoft Visual Studio 2010是否支持C99.如果没有,我怎么能使用像intptr_t和的标准类型uintptr_t?

c c99 visual-studio-2010 visual-studio

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

为什么C clock()返回0

我有这样的事情:

clock_t start, end;
start=clock();

something_else();

end=clock();
printf("\nClock cycles are: %d - %d\n",start,end);
Run Code Online (Sandbox Code Playgroud)

我总是得到一个输出"时钟周期是:0 - 0"

知道为什么会这样吗?

(只是为了给出一些细节,something_else()函数使用montgomery表示执行从左到右的求幂,而且我不确定something_else()函数确实需要一些不可忽略的时间.)

这是在Linux上.uname -a的结果是:

Linux snowy.*****.ac.uk 2.6.32-71.el6.x86_64 #1 SMP Fri May 20 03:51:51 BST 2011 x86_64 x86_64 x86_64 GNU/Linux

c linux clock

9
推荐指数
3
解决办法
3万
查看次数

如何以特定格式打印time_t?

ls命令以这种格式打印时间:

Aug 23 06:07 
Run Code Online (Sandbox Code Playgroud)

我如何转换,从接收到的时间stat()的mtime()这个格式的本地时间?

c linux time timezone ls

7
推荐指数
1
解决办法
3万
查看次数

C语言中CLOCKS_PER_SEC找到time.h库

CLOCKS_PER_SEC 是否因系统而异,或者它对于操作系统是恒定的还是依赖于该特定系统的处理器?并且还帮我解释我的代码的输出......是吗??

#include<stdio.h>
#include<time.h>
int main()
{
int a;
long int b;
clock_t start, end;

start = clock();

//Code for which the time is to be calculated
for(a=0;;a++)
{
    if(a<0)
    {
        break;
    }
}
printf("int : %u\n",a);
for(b=0;;b++)
{
    if(b<0)
    {
        break;
    }
}
printf("long int :%u\n",b);
//code is over

end = clock();

//CLOCKS_PER_SECOND : the number of clock ticks per second
printf("Starting Time:%u\n",start);
printf("Ending Time:%u\n",end);
printf("CLOCKS_PER_SEC:%u",CLOCKS_PER_SEC);
printf("\nNumber of clock ticks:%u",(end - start));
printf("\nTotal time:%u",(double)(end - start)/CLOCKS_PER_SEC);
return 0;
} …
Run Code Online (Sandbox Code Playgroud)

c clock

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

在Windows中使用C测量执行时间

我想衡量代码和平的执行时间.
我正在使用clock()函数.
这里的例子如下:

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

int main(void) {
    clock_t begin=0, end=0;

    begin = clock();
    printf("hello world!!\n");
    end = clock();

    printf("Begin %E\n",begin);
    printf("End %E\n",end);
    printf("Clocks %E\n",end-begin);
    printf("Clocks per second %E\n", CLOCKS_PER_SEC);
    printf("Time %E\n", (end-begin)/CLOCKS_PER_SEC);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

这里输出:

hello world!!
Begin 2.529616E-320
End 2.535545E-320
Clocks 5.928788E-323
Clocks per second 4.940656E-318
Time 0.000000E+00
Run Code Online (Sandbox Code Playgroud)

时间是0!
我做错了什么?输出是否正确?

非常感谢

c windows time

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