2012-08-24 2 views

답변

0

당신의 전체 문자열 읽으려면 :

// .str() returns a string with the contents of szBuffer 
muFunc(szBuffer.str()); 
// Once you've taken the string out, clear it 
szBuffer.str(""); 

당신이 (다음 \ n 문자까지) 다음 줄을 추출 할 경우, 사용 istream::getline :

// There are better ways to do this, but for the purposes of this 
// demonstration we'll assume the lines aren't longer than 255 bytes 
char buf[ 256 ]; 
szBuffer.getline(buf, sizeof(buf)); 
muFunc(buf); 

의 getline을()는 구분 기호를 두 번째 매개 변수 (기본적으로 \ n)로 사용할 수 있으므로 단어 단위로 읽을 수 있습니다.

관련 문제