I am using timeval structure in order to get current system time. Normally if I declare it like that:
timeval curtime;
it is working. However I saw some code where people declare it as:
struct timeval curtime;
Is there any difference between these two?
In C, you must use struct
prefix when declaring a variable with a struct type.
In C++, it's not required to prefix with struct
.
Since you have tagged this as a C++ question, I assume you are using a C++ compiler and so you do not get a compiler error when you use timeval
without the struct
prefix. However, if you were to use a C compiler, it would issue an error.