Thank you for reading my thread.

I am experiencing an issue using struct tm and I can't figure out what I am doing wrong. I have looked at several examples and read up on the structure, but to me it all looks right. I would appreciate some fresh eyes on my code and hopefully a resolution. Below is a piece of test code that I wrote in which I receive an error stating I did not set theTime to tm* as in my larger program. By the way my compiler is MINGW if that helps.

Test Code

#include <windows.h>
#include <time.h>
#include <iostream>
using namespace std;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
	time_t seconds;
	struct tm *theTime;
	theTime = localtime(&seconds);
	int aHour = theTime.tm_hour;
	int aMin = theTime.tm_min;
	if(aHour == 1)
		if(aMin == 40)
cout << "Exit";



$ g++ -mwindows "background app.cpp" -o bapp.exe
background app.cpp: In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':
background app.cpp:15: error: request for member `tm_hour' in `theTime', which is of non-class type `tm*'
background app.cpp:16: error: request for member `tm_min' in `theTime', which is of non-class type `tm*'

Thank you for reviewing my issue any help is greatly appreciated.

6 Years
Discussion Span
Last Post by shaynerossum

You need the arrow -> and not the . on lines 15 and 16 because theTime is a pointer.

Edited by jonsca: n/a

Votes + Comments
Thank you very simple solution.

Thank you very much compiled without any errors now I just have to work on some other things.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.