[temp] std::ifstream을 std::string으로..
Apr 27
Programming/C/C plus plus ifstream, std::ifstream(), std::string, string 27 Comments
말 그대로 std::ifstream을 std::string으로 변환하는게 성능은 그냥 file open해서 하는 것 보다 60배 정도 느리다. -_-;;;
확인은 안 해봤지만…
iPhone Developer
Apr 27
Programming/C/C plus plus ifstream, std::ifstream(), std::string, string 27 Comments
말 그대로 std::ifstream을 std::string으로 변환하는게 성능은 그냥 file open해서 하는 것 보다 60배 정도 느리다. -_-;;;
확인은 안 해봤지만…
Mar 29
Programming/C/C plus plus dos file, ifstream, seekg(), std::ifstream(), tellg(), unix text file No Comments
그 사실을 모르거나 깜빡하고 있을 때, 아주 난감하고 많은 시간을 들여야 풀리는 문제..
최근에도 std::ifstream::tellg와 std::ifstream::seekg() 때문에 아주 난감했다.
그래서 std::ifstream을 잘 쓰지 않는데 좀 급한 마음에 생각 없이 쓴게 말썽을 부렸다.
Unix text file을 windows에 읽을 때 line feed (‘\n’)가 carriage return과 line feed로 바뀌게 되는 것을 잘 알 것이다. (‘\r\n’)
문제는 tellg()가 ‘\r’을 만날 때 file pointer를 변경 시킨다는 것이다. (그래서 무한 loop에 빠지는 경우가 있다) 또한 seekg도 file pointer를 변경 못하는 경우도 있다.
아래 news group에서 이와 같은 문제에 대해서 토론을 했고 특히, Eivind Grimsby Haarr의 example 처럼 동일한 코드에서 tellg만 써버려도 코드가 오 동작을 한다.