문자열 -> 숫자 변환하는 함수
1. stoi, stof, stod, stol
std::string str = "42";
int n = std::stoi(str); // string to int
float f = std::stof(str); // string to float
double d = std::stod(str); // string to double
long l = std::stol(str); // string to long
2. stringstream
#include <sstream>
std::string str = "42";
std::stringstream ss(str);
int n;
ss >> n; // 자바의 Integer.parseInt() 느낌
'코딩 학습 > C와 C++' 카테고리의 다른 글
| C++ 팀프로젝트 - 텍스트 RPG 게임 만들기(1) (0) | 2026.03.26 |
|---|---|
| C++ 기초 - 찾고, 자르고, 바꾸기 (0) | 2026.03.25 |
| C++ 기초 - 포션 공방 만들기 과제 (0) | 2026.03.23 |
| C++ 기초 - Vector 템플릿 구현하기 (0) | 2026.03.20 |
| C++ 기초 - 언리얼 엔진 기본 개념 (0) | 2026.03.19 |