How to print a number with a space as thousand separator?
<p>I've got a simple class Currency with overloaded operator&lt;&lt;. I don't know how can i separate the number with spaces every 3 digits, so it looks like: "1 234 567 ISK".</p>

<pre><code>#include &lt;cstdlib&gt;
#include &lt;iostream&gt;

using namespace std;

class Currency
{
    int val;
    char curr[4];

    public:
    Currency(int _val, const char * _curr)
    {
        val = _val;
        strcpy(curr, _curr);
    }

    friend ostream &amp; operator&lt;&lt; (ostream &amp; out, const Currency &amp; c);
};

ostream &amp; operator&lt;&lt; (ostream &amp; out, const Currency &amp; c)
{
    out &lt;&lt; c.val&lt;&lt; " " &lt;&lt; c.curr;
    return out;
}

int main(int argc, char *argv[])
{
    Currency c(2354123, "ISK");
    cout &lt;&lt; c;
}
</code></pre>

<p>What interests me, is somehow the easiest solution for this particular situation.</p>
