[C++] stream.getline()함수에서 stream의 중간에 \0(null)이 있
글쓴이: gyxor / 작성시간: 토, 2004/04/24 - 11:58오후
#include<iostream> #include<fstream> #include<istream> #include<sstream> using namespace std; int main(){ char data[20] = "abc\0eee"; char temp1[20] ={0}; char temp2[20] ={0}; istringstream is(data); is.getline(temp1,4); is.getline(temp2,4); cout << temp1 << endl << temp2; return 0; } 결과 abc
위 소스처럼 스트림의 중간에 abc\0eee
null문자가 있는경우에 뒤에 있는 스트림은 못읽었습니다.
null문자를 건너뛰고..
뒤에 있는 스트림을 읽어 들일수 있는 방법은 없나요?
답변부탁드립니다.
Forums:
무식하게 한글자씩 읽어들이거나stream대신에 streambuf에 직
무식하게 한글자씩 읽어들이거나
stream대신에 streambuf에 직접 접근하는 방법이 있을 거 같군요
댓글 달기