'ctime lib, pointer in C++
tm *ltm = localtime(&now);
cout << "Year: "<< 1900 + ltm->tm_year << endl;
in ctime lib
why we must use ltm->tm_year but can't use *1tm.tm_year
Solution 1:[1]
Because of the precedence of operators in c++
*1tm.tm_year
means
*(1tm.tm_year)
you can do
(*1tm).tm_year
but thats a bit ugly, hence this:
1tm->tm_year
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pm100 |
