Hi everyone,
In the program I am writing I need to include a time stamp which need to be in the form: "time: 2011-09-08 14:21:44.4730". I have achieved this by doing:
I was thinking of using a #define like so #define TIME_STAMP_INFO <<lt.wYear<<"-"<< ::std::setfill('0')<< ::std::setw(2)<<lt.wMonth<<"-"<<::std::setw(2)<<lt.wDay<<" "<< ::std::setw (2)<<lt.wHour<<":"<<::std::setw(2)<<lt.wMinute<<":"<<::std::setw(2)<<lt.wSecond<<"."<<::std::setw(3)<<lt.wMilliseconds<<"0"
In C this is probably what I would have done, but I'm sure there is a better way to do it in C++. Normally you can use const in C++ where I had previously used #define in C, however I can't seem to work it out for this. Anybody have any ideas? Also is there anyway for a #define to continue onto another line? The statement would be about 250 characters long which is more than twice what I would like any of my lines of code to be.
And yes I have looked into the differences of #define and const etc. But I can't seem to find something on the internet that answers this problem. (Although I'm very possibly just searching for the wrong thing)