![]() |
| | #1 |
| Registered User Join Date: Oct 2008
Posts: 7
| When I debug it, I get "Error 2 error C2228: left of '.tm_mon' must have class/struct/union". Which I don't get since I thought I had declared it. Code: #include <stdio.h>
#include <iostream>
#include <ctime>
using namespace std;
int main ()
{
char test;
time_t now;
tm *today;
time(&now);
today=localtime(&now);
cout << today.tm_mon << endl;
cout << "Did it work?";
cin >> test;
return 0;
}
|
| MGrancey is offline | |
| | #2 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| It's a pointer to a struct. So it's today->tm_mon;
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #3 |
| C++ Witch Join Date: Oct 2003 Location: Singapore
Posts: 10,354
| Since today is a pointer, it should be today->tm_mon.
__________________ C + C++ Compiler: MinGW port of GCC Build + Version Control System: SCons + Bazaar Look up a C/C++ Reference and learn How To Ask Questions The Smart Way |
| laserlight is online now | |
| | #4 |
| Registered User Join Date: Oct 2008
Posts: 7
| Thanks, that was a silly thing to miss when I read that several times. |
| MGrancey is offline | |
![]() |
| Tags |
| date, localtime, struct tm, time |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Link List math | t014y | C Programming | 17 | 02-20-2009 06:55 PM |
| Assignment HELP!! | cprogrammer22 | C Programming | 35 | 01-24-2009 02:24 PM |
| Help please im stuck | ItsMeHere | C Programming | 7 | 06-15-2006 04:07 AM |
| Search Engine - Binary Search Tree | Gecko2099 | C Programming | 9 | 04-17-2005 02:56 PM |
| Request for comments | Prelude | A Brief History of Cprogramming.com | 15 | 01-02-2004 10:33 AM |