Convert string to float in c++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Convert string to float in c++

Hello! For example, i've got a string with text like "4*2" and how can i get a result of 4*2? p.s. sorry for my bad english :)

4th Dec 2018, 11:19 AM
ПризракTM
ПризракTM - avatar
2 Answers
+ 6
Use std::stof from <string> library ¹ [To see the example follow the footer link] "sorry for my bad english :)" Your English is awesome, IMO! 8) _____ ¹ http://www.cplusplus.com/reference/string/stof/
4th Dec 2018, 11:40 AM
Babak
Babak - avatar
+ 1
oh, thanks a lot!)
4th Dec 2018, 12:09 PM
ПризракTM
ПризракTM - avatar