0
How to convert a string x="172" into int??
2 ответов
+ 4
here's an example:
#include <cstdlib>
char input_line[ 30 ];
int main() {
cout << "Enter a number: ";
cin.getline(input_line, 29);//29 is one less than input_line's 30, for the null character
int x = atoi(input_line);//atoi() is a function in cstdlib that converts string to int
cout << "Variable x is equal to " << x << endl;
return 0;
}
- 2
Idk tbh