How to calculate running time in C language [closed] - c

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
The following function is not compiling:
double GetCurTime()
{
LARGE_INTEGER CounterFreq;
QueryPerformanceFrequency(&CounterFreq);
LARGE_INTEGER Counter;
QueryPerformanceCounter(&Counter);
return (double)Counter.QuadPart / (double)CounterFreq.QuadPart;
}
The C the compiler I am using does not recognize LARGE_INTEGER and QueryPerformanceFrequency.
If anyone recognizes these items, can you please suggest where I might find them?
Perhaps they are in a header file, or a library that I do not currently have.

Include the <time.h> library and use the time_t time(time_t *timer); function.
Also, if you want to use QueryPerformanceCounter, then you need to include Winbase.h (and Windows.h).

Related

Error in C program, using VS2017 for the first time [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I getting code 0 error while compiling very simple code. How do I solve it?
I using VS 2017 for the first time.
#include <stdio.h>
void main()
{
printf("My name is Haim");
}
The two rows in the middle are not supposed to be there!
Haim
Your main() should return some exit code. So int should be as the return type.
In the other hand exit code 0 means, that everything was succesfull, see.

What is the special macro of buffer size in standard C library? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I saw this special macro when I read a source code. If I remember correctly, it is defined in the standard library.
The name of this macro is related to the buffer size, and in my machine its implementation is 1024.
Now I want to use it to initialize the buffer but I forgot what it is called.
So is there any one who can help me make my code look more professional?
If I don't know what I am looking for specifically, how can I clearly say what I need?
Are you talking about BUFSIZ? It's a macro provided by <stdio.h> and it expands to the size of the buffer used by setbuf().
I'm not sure what use it has in your own code.

Why don’t we have to call main function in C? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I just had a question that whenever I write code I had to call all functions (predefined or user defined) in order to use or execute them. So why we don't have to call main function?
The main function is defined by the language itself as the designated start of the program. You don't need to call it because, in effect, your operating system (Linux, macOS, Windows, etc.) does.

C: recognize variable type [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I'm learning C. I wonder whether there is an instruction or command to recognize the type of the variable.
To be more practical: I have a program which works with integers, I want to show an error message if the user inserts a real number when running the program.
Hope you can help!
This is not part of the C standard, but GCC has the typeof keyword.
You have to be using the GCC compiler for it though.

offsetof with char as second argument. Is it possible? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'd love to create some part dynamically. Would it be possible to use offsetof with string as a second argument? Something like:
offsetof( tic, "close.v");
Or can I convert char to member anyhow?
The offsetof construct is a compile time operation. It can't be used with anything that is generated dynamically.

Resources