C++ conversione stringa_int
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
#include <cstdlib> #include <iostream> #include <string> #include <sstream> using namespace std; string intTOstring(int value) { stringstream ss; ss<<value; return(ss.str()); } int main(int argc, char *argv[]) { int n=10; string str="A"; str+=intTOstring(n); cout<<str; //stampa A10 string a="25"; int b=atoi(a.c_str()); cout<<b; system("pause"); return 0; } |