I'm trying to use stringstreams for getting ints into a string. I do it like this:
std::string const DilbertImage::startUrl = "http://tjanster.idg.se/dilbertimages/dil";
std::string const DilbertImage::endUrl = ".gif";
DilbertImage::DilbertImage(int d)
{
cal.setDate(d);
int year, month, date;
year = cal.getYear();
month = cal.getMonth();
date = cal.getNumDate();
std::stringstream ss;
ss << year << "/";
if(month < 10)
{
ss << 0;
}
ss << month << "/" << "Dilbert - " << cal.getNumDate() << ".gif";
filePath = ss.str();
ss.str("");
ss.clear();
ss << startUrl << date << endUrl;
url = ss.str();
std::cout << url << '\t' << filePath << std::endl;
}
I expect to get two nice strings that look like this:
url: http://tjanster.idg.se/dilbertimages/dil20060720.gif
filePath: /2006/07/Dilbert - 20060720.gif
But instead when I put the ints in the stringstream they somehow endup getting spaces (or some other blank character inserted in the middle of them) When I paste it from the console window the character shows as a *.
They end up looking like this:
url: http://tjanster.idg.se/dilbertimages/dil20*060*720.gif
filepath: /2*006/07/Dilbert - 20*060*720.gif
Why is this happening?
Here is the whole project: http://pastebin.com/20KF2dNL