0

Possible Duplicate:
Alternative to itoa() for converting integer to string C++?
How to convert a number to string and vice versa in C++
Append an int to a std::string

I want to convert integer to string, any one help me for these conversion?

itoa(*data->userid,buff1,10); itoa(*data->userphone,buff2,10); 
2
  • 3
    To everyone who posted answers below, instead of feeding yet another duplicate and chasing SO scores, you'd be better voting to close it as a duplicate. Commented Jun 27, 2012 at 9:23
  • 1
    three possibilities: stackoverflow.com/questions/10516196/… Commented Jun 27, 2012 at 9:29

2 Answers 2

9

For C++, use std::stringstream instead.

#include <sstream> //... std::stringstream ss; ss << *data->userid; std::string userId = ss.str(); 

or std::to_string if you have access to a C++11 compiler.

Sign up to request clarification or add additional context in comments.

Comments

4

If you have a C++11 compiler with the new std::to_string function you can use that. Otherwise use the std::stringstream solution by Luchian.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.