I am having a problem with the ctime() function defined in the header included by #include <ctime>.
The function is supposed to return a string in the format:
Www Mmm dd hh:mm:ss yyyy
Where Www is the weekday, Mmm the month in letters, dd the day of the month, hh:mm:ss the time, and yyyy the year.
There should only be one space between each thing. I just encountered a situation where the returned string had two spaces after the month, which breaks my properlyFormatDateAndTime() function's algorithm which depends on the above format. The string returned by the ctime function just a couple of minutes ago, looks like this:
As you can see, there are two spaces after the month, instead of just one. I don't know why that is, but just thought I'd go ahead and post about it before the behavior went away (seeing as it doesn't do that all the time, as I just ran my program which has the properlyFormatDateAndTime() function the other day, and it worked fine, and as expected, then).Code:Wed Mar 2 10:59:10 2011
EDIT: Ok, this is even weirder. The above is what I thought was happening, but actually this is what the ctime function is returning:
I was reporting the output of a C++ string before that had the content of the C-style string returned by ctime assigned to it (because I assumed the content would be the same), but then I decided to check the content of the actual C-style string, and the above is what it is returning now, and what the C++ string which gets the content of the C-style string returned by ctime contains is this:Code:' Wed Mar 2 11:12:33 2011
As you can see, the C++ string is missing the beginning hyphen and space that the original string contained for some reason.Code:Wed Mar 2 11:12:33 2011