ifstream으로 string객체에 line단위로 읽어오기...

purewell의 이미지

...
ifstream ifs("hello.txt");
char buff[256];
ifs.geline(buff, 256);
...

위에서 쓰인 "char buffer[256]" 대신 std::string객체를 쓸 수 있는
방법 있나요? ㅡ_-)/ string객체로 읽어오면 크기 생각 안 하고 읽어도
될 것 같아서요... 물론...

...
string strbuffer;
ifs >> strbuffer;
...

이래도 되지만, 라인단위로 읽어오는 것이 아니라
white-space를 구분자로 해서 읽어오잖아요.

방법이 없을까요?

vigor96의 이미지

int main()
{
	ifstream input("temp.txt");
	string str;
	getline(input, str);

	cout << str;


}

이렇게 쓰면 되는것 같은데요..

흠....