Code Snippets

  

C++ Source Code


Welcome to Dream.In.Code
Become a C++ Expert!

Join 148,902 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,315 people online right now. Registration is fast and FREE... Join Now!





Integer to string conversion

Program uses std::ostringstream which is defined in sstream to convert integer to string.

Submitted By: Xing
Actions:
Rating:
Views: 27,353

Language: C++

Last Modified: November 20, 2006

Snippet


  1. #include <iostream>
  2. #include <sstream>
  3.  
  4. int main() {
  5.     std::ostringstream stm;
  6.  
  7.     // Output an int
  8.     stm << 2500;
  9.  
  10.     // Retrieve the resulting string
  11.     std::cout << stm.str() ;
  12.  
  13.     return 0;
  14.   }
  15.  

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.




Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month