+ 1

How would you convert a string to a int?

3rd Oct 2017, 1:46 AM
Deshaun Spence
Deshaun Spence - avatar
6 Respuestas
+ 14
// In C++ #include <iostream> #include <string> using namespace std; int main() { string str = "12345"; // a string of numbers for (const auto &i : str) cout << (i - '0') << endl; } Output: 1 2 3 4 5
3rd Oct 2017, 7:23 AM
Babak
Babak - avatar
0
java
3rd Oct 2017, 1:58 AM
Deshaun Spence
Deshaun Spence - avatar
0
For example: int age; double weight, height; double weightin= weight/2.2; double heightpo= height*0.39; double BMR= 6.2*weight + 12.7*height - 6.76*age+66; how would I convert this using the double.parsedouble() and integer.parseInteger (); ?
3rd Oct 2017, 2:05 AM
Deshaun Spence
Deshaun Spence - avatar
0
thankyou
3rd Oct 2017, 2:06 AM
Deshaun Spence
Deshaun Spence - avatar