Created
September 17, 2014 02:29
-
-
Save ashwin/20e8f60cf3df2babebe3 to your computer and use it in GitHub Desktop.
Convert int or float to string in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
int main() | |
{ | |
int i = 9876; | |
float f = 3.14; | |
std::string si = std::to_string(i); | |
std::string sf = std::to_string(f); | |
std::cout << si << " " << sf << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment