Skip to content

Instantly share code, notes, and snippets.

@ashwin
Created September 17, 2014 02:29
Show Gist options
  • Save ashwin/20e8f60cf3df2babebe3 to your computer and use it in GitHub Desktop.
Save ashwin/20e8f60cf3df2babebe3 to your computer and use it in GitHub Desktop.
Convert int or float to string in C++
#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