I wanted to know a simple way to convert a variable float
or int
in data type string
in C++
. Because look in several places and talk about using sprintf
, from the library stdio.h
but it does not work with string
but with char
.
For example, to a number 1564.53 I want to pass it to "1564.53" but I want that string
not to be lost but saved in a variable of type string
.
For what I need is to return a balance in currency format, that is, with the sign $ pesos at the beginning followed by the value of the balance, but this is in float
.