字符串流的使用

#include <iostream>
#include <sstream>
using namespace std;

string compose(const char* file, int line, const string& message)
{
    ostringstream os;
    os << "(" << file << "," << line << "):" << message;
    return os.str();
}

int main()
{
    cout << compose("file.txt", 5, "lack of argument");
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/lhb666aboluo/p/12812724.html