C++ Get Current date output weird result
<p>My output is unreadable, all i wanted to do is assign the day month year into a string.</p>

<p>if i cout them by now->tm_year+1900 , it works, but if i assign it to a string and cout later, it output like this. how do i change my code so i can assign the value to string without losing reference later on cout.</p>

<p>Terminal:</p>

<pre><code>Date is 
</code></pre>

<p>My code:</p>

<pre><code>int main()
{
//get today date
string year,month,day;

/* Output 6 month frame for appointment booking*/
 time_t t = time(0);   // get time now
 struct tm * now = localtime( &amp; t );

year = now-&gt;tm_year + 1900;
month = now-&gt;tm_mon + 1;
day = now-&gt;tm_mday;

cout &lt;&lt; "Date is " &lt;&lt; year &lt;&lt; month &lt;&lt; day &lt;&lt; endl;

return 0;
}
</code></pre>
