여러가지 자료형이 한 줄에 들어오면 파싱해서 용도에 맞게 사용해야 한다. 예를 들어 “이름 날짜 내용” 과 같은 문자열로 한 줄의 데이터로 들어오면 파싱하여 사용함
주어진 문자열에서 필요한 자료형에 맞는 정보를 꺼낼 때 사용
공백과 ‘\n’을 제외하고 문자열에서 맞는 자료형의 정보를 빼냄
int num;
string str = "123 456";
stringstream stream;
stream.str(str);
while(stream1 >> num ) cout << num << endl;
int num;
string str = "123 456";
stringstream stream;
stream.str(str);
while(stream1 >> num ) cout << num << endl;
stream.str("");//초기화