Reputation: 7491
I dont understand the part: struct tm * timeinfo;
what does this mean? Why there's a star there? Thanks!
int main ()
{
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "The current date/time is: %s", asctime (timeinfo) );
return 0;
}
Upvotes: 0
Views: 167
Reputation: 93556
localtime() returns a pointer to an internal copy of a tm structure. struct tm* declares a pointer to a tm struct.
Upvotes: 0
Reputation: 7878
That's a pointer in C/C++. Pointer is a basic function of C language.
Upvotes: 0
Reputation: 361712
struct tm * timeinfo;
It's declaring a variable timeinfo of type struct tm*
. This is C-syntax.
In C++, you don't need to write struct
keyword. Just tm * timeinfo
is enough!
Upvotes: 2
Reputation: 100151
If you really don't know how pointers are declared in C++, you need to do more reading than will fit into an answer here. The *
declares pointer to
.
Upvotes: 4