Linked Questions
24 questions linked to/from What’s the correct way to use printf to print a clock_t?
0 votes
1 answer
2k views
Working with clock_t in C [duplicate]
I'm working on a little school project to re-code the SpaceInvaders Game, without using ncurses, but only the basic libraries, and i want to use time to print my screen-buffer every time, so i need to ...
-1 votes
1 answer
1k views
Strange CLOCKS_PER_SEC values using time.h [duplicate]
Currently I'm trying to time a process to compare with a sample program I found online that used opencl. Yet when I try to time this process I'll get very strange values as shown below. #include <...
62 votes
10 answers
127k views
Are there types bigger than long long int in C++?
Are there types bigger than long long int in C++? My compiler is g++.
59 votes
4 answers
145k views
What primitive data type is time_t? [duplicate]
I do not know the data type of time_t. Is it a float double or something else? Because if I want to display it I need the tag that corresponds with it for printf. I can handle the rest from there for ...
38 votes
4 answers
37k views
Format specifiers for implementation-defined types like time_t
I want to make my code more platform-/implementation-independent. I don't know what a time_t will be implemented as on the platform when the code is being compiled. How do I know the type of t to ...
12 votes
7 answers
45k views
why C clock() returns 0
I've got something like this: clock_t start, end; start=clock(); something_else(); end=clock(); printf("\nClock cycles are: %d - %d\n",start,end); and I always get as an output "Clock cycles are: 0 ...
26 votes
4 answers
15k views
How to print types of unknown size like ino_t?
I often experience situations where I want to print with printf the value of an integer type of implementation-defined size (like ino_t or time_t). Right now, I use a pattern like this for this: #...
28 votes
2 answers
20k views
How to use printf to display off_t, nlink_t, size_t and other special types?
In my program, I stat the files they want and send the data over. The fields of a stat struct are all special types: struct stat { dev_t st_dev; /* ID of device containing file */ ino_t ...
13 votes
3 answers
21k views
Does Microsoft visual studio 2010 support c99?
I would like to know if Microsoft Visual Studio 2010 supports C99. If not, how can I use the standard types like intptr_t and uintptr_t?
10 votes
1 answer
46k views
How to print time_t in a specific format?
ls command prints time in this format: Aug 23 06:07 How can I convert time received from stat()'s mtime() into this format for local time?
3 votes
3 answers
15k views
C Program measure execution time for an instruction
I need to find the time taken to execute a single instruction or a few couple of instructions and print it out in terms of milli seconds. Can some one please share the small code snippet for this. ...
2 votes
1 answer
11k views
CLOCKS_PER_SEC in C language found the time.h library
Does CLOCKS_PER_SEC varies from system to system or is it constant for an operating system or is it dependent on the processor of that particular system?? And also do help me explain the output of my ...
3 votes
2 answers
1k views
How to get the largest precision floating point data type of implemenation and its printf specifier?
Or put differently, are there equivalents to intmax_t and %jd but for floating point numbers? This has already been asked as a side question here, but the question is so large that I think people ...
2 votes
1 answer
1k views
Why does clock_t only give me integers in C
I'm trying to clock a sorting function, pretty straightforward stuff. Code looks like: clock_t start_t, end_t, total_t; start_t = clock(); sort(); end_t = clock(); total_t = (double)(end_t - start_t) ...
-3 votes
1 answer
2k views
How to find the execution time of code in C?
I found this code here. If I divide (t2-t1)/CLOCK_PER_SECwill i get time in seconds? How to I find CLOCK_PER_SEC? Is there any better way to find the execution time of a code or a function? #include&...