Casting

if the user enter
1
2
 int n ;
 cin >> n ;


and then i want to put the value of number of n in a string
this give me error

 
string str = {n} ;


what should i do ?
You can't just put a number into a string (or vice versa) so you'd need to either write a function to do that yourself or use one that already exists(for example: http://www.cplusplus.com/reference/clibrary/cstdlib/itoa/ )
Last edited on
Topic archived. No new replies allowed.