Possible duplicate:How to convert a number to a string and vice versa in C ++
Dow convert integral value to string in C ++?
string
Here is what I tried:
for(size_t i = 0;vecServiceList.size()>i;i++) { if ( ! vecServiceList[i].empty() ) { string sService = "\t" + i +". "+ vecServiceList[i] ; } }
And here is the error:
invalid operands of types 'const char*' and 'const char [3]' to binary 'operator+'
You can use a stream of lines:
#include <sstream> ... for (size_t i = 0; ... ; ...) { std::stringstream ss; ss << "\t" << i << vecServiceList[i]; std::string sService = ss.str(); // do what you want with sService }
Source: https://habr.com/ru/post/915253/More articles:str in Python 2.7 does not have __iter__, but it acts as iterable. What for? - iteratorIs there a way for Oracle Data Integrator to extract data from MongoDB - oracleCreating a property that LINQ to Entities can translate - c #calling the base method using the new keyword - methodspartial error when using boost :: enable_shared_from_this - c ++How to enlarge a circle with increasing text inside a circle? - htmlIs the concept of an algebraic data type close to class definitions in OO languages? - algebraic-data-typesHow to convert this Backus-Naur form expression to Regex (.Net)? - regex"machine sleep" + WaitForSingleObject + end timeout - mutexMule ESB can be deployed to Application Server - esbAll Articles