c++ 3桁ずつコンマ comma

int rem=dollars%1000;
char buf[128];
sprinf(buf, ",%3d", rem);
string s = string("hoge") + buf;

1つのhint.