這篇文章將為大家詳細(xì)講解有關(guān)C++string格式化輸出方式是什么,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
利用boost的format
頭文件
#include
boost::format f = boost::format("%.2f %s %d") % 1.234 %"123" % 12; std::string s = f.str();
等同于
boost::format f = boost::format("%.2f %s %d"); f % 1.234 %"123" % 12; std::string s = f.str();
類似CString的格式化
CString t = L"123"; CString s; s.Format(L"%.2f %s %d", 1.234, t, 12);
關(guān)于C++string格式化輸出方式是什么就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。