#include <sstream> #include <iostream> int main() { for (int i = 0; i < 100; ++i) { std::ostringstream buff; buff << "C://dossier" << i << ".txt"; const std::string path = buff.str(); std::cout << path << std::endl; } return 0; }
#include <sstream> #include <iostream> #include <vector> int main() { std::vector<std::string> > tab; for (int i = 0; i < 100; ++i) { std::ostringstream buff; buff << "C://dossier" << i << ".txt"; const std::string path = buff.str(); tab.push_back(path); } for (int i = 0; i < tab.size(); ++i) std::cout << tab[i] << std::endl; return 0; }
Améliorez votre expérience CodeS-SourceS avec ce plugin:
http://codes-sources.commentcamarche.net/forum/affich-10000111-plugin-better-cs-2#cptpingu-signature
std::string tableau[100]; for (int i=0; i<100; i++) { char nb[8]; sprintf(nb,"%d", i); tableau[i]="C://dossier" + std::string(nb) + ".txt"; }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question