C++ create string of text and variables

前端 未结 6 996

I\'m trying to do something very simple and yet, after an hour of so of searching a I can\'t find a suitable answer so I must be missing something fairly obvious.

I\

6条回答
  •  余生分开走
    2020-12-24 11:24

    In C++11 you can use std::to_string:

    std::string var = "sometext" + std::to_string(somevar) + "sometext" + std::to_string(somevar);  
    

提交回复
热议问题