OK, so this kinda goes along with the other post i made. In my app i'm storing the dates as MMDD in a deque <int> but i would like to output the date to the console as MM/DD what would be the best way to do this.
OK, so this kinda goes along with the other post i made. In my app i'm storing the dates as MMDD in a deque <int> but i would like to output the date to the console as MM/DD what would be the best way to do this.
Sorry, but i'm a Code::Blocks man now.
So you're storing the month & day together in one int between 0101 & 1231?
Well I'd say the easiest way would be to convert the int into a string, then stick a '/' in the middle. You'll have to make sure the int gets a leading 0 when it converts to a string if the month is < 10.
Well i'm storing it as an int because i'm sorting it by date. e.g. 612 > 610, so it goes before it in the list. So i'd be making life hard if i used it as a string. Unless i make a temporary string, assign it the value held in the int then stick the '/' in it and use that to print to the screen...
Sorry, but i'm a Code::Blocks man now.
You can sort strings. You can also store the month and day separately in a struct or class and sort by the class. You can overload the operator<< for the class and have it output the date in whatever format you want.
>> Interesting idea, although a bit much for this application.
Perhaps. It might also be less code than what you've got now, and it's the "right" way to do it.