C++ MFC Get current date and time

Viewed 43300

I've been programming in VB.NET for most of my very programming career. I have a C++ project provided to me, which I need to make a few modifications, and I am feeling hopelessly lost and confused.

It is a Visual Studio 2008 MFC project in C++.

an output variable has been defined:

char szout[900];

This line below, is used to append values to the output variable before output:

strcpy(szout, "TextHere")

So one of the many examples from searching, that i have tried, was to include at the top:

#include <windows.h>

And then for my code:

SYSTEMTIME st;
GetSystemTime(&st);
char myDate[20] = st;
CT2CA outputDate(myDate);
strcat(szout, outputDate);

For some reason the variables appended on to szout must be of type CT2CA, which i'm not really sure what this is either.

But then I get the following errors on the second and third line (char myDate...etc...) and (CT2CA output....etc....)

error C2440: 'initializing' : cannot convert from 'SYSTEMTIME' to 'char [20]'

error C2664: 'ATL::CW2AEX<>::CW2AEX(LPCWSTR) throw(...)' : cannot convert parameter 1 from 'char [20]' to 'LPCWSTR'

So I'll clarify, I am a complete novice with this, and would appreciate any and all help.

Thank you,

2 Answers
Related