int to string

If you insist on using C
C++ Syntax ( Toggle Plain Text)
    
    
    
    
  1. char* result;
  2. int num = 24;
  3. sprintf ( result, "%d", num );
  4. std:: string str (result );

Do this if you want  to  use  C++
C++ Syntax ( Toggle Plain Text)
    
    
    
    
  1. int someint = 24;
  2. std:: stringstream strm;
  3. std:: string num;
  4. strm << someint;
  5. strm >> num;

你可能感兴趣的:(String)