C++ stoi()

1 개요[ | ]

C++ stoi()
C++
Copy
#include <iostream>
using namespace std;
int main() {
	string str = "123";
	int n = stoi(str);
	cout << n; // 123	
}
Loading
C++
Copy
#include <iostream>
using namespace std;
int main() {
	string str = "123xxx";
	int n = stoi(str);
	cout << n; // 123	
}
Loading
C++
Copy
#include <iostream>
using namespace std;
int main() {
	string str = "000123";
	int n = stoi(str);
	cout << n;
}
Loading
C++
Copy
#include <iostream>
using namespace std;
int main() {
	string str = "xxx123";
	int n = stoi(str);
	cout << n;
}
Loading

2 같이 보기[ | ]