std::string formatting like sprintf

前端 未结 30 2957
野趣味
野趣味 2020-11-22 04:42

I have to format std::string with sprintf and send it into file stream. How can I do this?

30条回答
  •  执笔经年
    2020-11-22 05:06

    Very-very simple solution.

    std::string strBuf;
    strBuf.resize(256);
    int iCharsPrinted = sprintf_s((char *)strPath.c_str(), strPath.size(), ...);
    strBuf.resize(iCharsPrinted);
    

提交回复
热议问题