char β int
μμ€ν€ μ½λ νμ© ( β0β μ λΉΌμ€λ€ )
ex) char β3β β int 3 μΌλ‘ λ³ν
β3β - β0β : 3
int β char
β0β μ λν΄μ£Όλ©΄ λλ€
#include <bits/stdc++.h>
using namespace std;
int main() {
int a = 3;
cout << (char)(a + '0'); // '3'
}
C++
볡μ¬
int β string
β’
to_string() μ¬μ©
β’
int λΏλ§ μλλΌ λͺ¨λ μ«μ νμ
μ μ¬μ©κ°λ₯νλ€.
#include <bits/stdc++.h>
using namespace std;
int main() {
int a = 123456;
cout << to_string(a); // "123456"
}
C++
볡μ¬
string β int
β’
stoi (string to int)
β’
cf
β¦
stof : string to float
β¦
stol : string to long
β¦
stod : string to double
#include <bits/stdc++.h>
using namespace std;
int main() {
string s = "100";
int i = stoi(s); // string -> int
cout << i; // 100
}
C++
볡μ¬