0
int x;
float f;
std::string s = "3.7";
std::istringstream is(s);
is >> x >> f;
'x'와 'f'의 결과가 3과 0.7 인 이유는 무엇입니까?
제가std :: istringstream의 결과를 이해하는 방법은 무엇입니까?
is >> f;
'F'의 결과를 사용하여 3.7이다.
int x;
float f;
std::string s = "3.7";
std::istringstream is(s);
is >> x >> f;
'x'와 'f'의 결과가 3과 0.7 인 이유는 무엇입니까?
제가std :: istringstream의 결과를 이해하는 방법은 무엇입니까?
is >> f;
'F'의 결과를 사용하여 3.7이다.
istreamstream은 fit into the target datatype (산술 유형 참조)과 같이 스트림에서 많은 문자를 추출합니다. 다른 정지 조건은 공백 문자입니다.
그래서 다음에 코드를 변경한다면 :
int x;
char c;
int f;
std::string s = "3.7";
std::istringstream is(s);
is >> x;
is >> c;
is >> f;
std::cout << x << std::endl;
std::cout << c << std::endl;
std::cout << f << std::endl;
이 다음과 같은 출력을 초래할 것입니다 : (". 7")
3
.
7
내 대답이 도움이된다면 정답으로 표시하는 것이 좋을 것입니다. –
'표준 : istringstream이다; >> f;' –