Как может <<использоваться для построения строкового крыла
int iCount;
char szB[128];
sprintf (szB,"%03i", iCount);
using namespace std;
stringstream ss;
ss << setw(3) << setfill('0') << iCount;
string szB = ss.str();
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
using namespace std;
int main() {
int iCount = 42;
ostringstream buf;
buf << setw(3) << setfill('0') << iCount;
string s = buf.str();
cout << s;
}
Как <<< можно использовать для построения строки ALA
, это не имеет никакого смысла.
Использование STD :: OstringStream
в C ++, если вы хотите сделать подобную вещь.
std::ostringstream s;
int x=<some_value>;
s<< std::setw(3) << std::setfill('0') <<x;
std::string k=s.str();