stdio_getline.cpp 492 B

123456789101112131415161718192021222324
  1. //
  2. // $Id$
  3. //
  4. #include<__vic/stdio_file.h>
  5. namespace __vic {
  6. //----------------------------------------------------------------------------
  7. bool getline(std::FILE *fp, std::string &buf, char delim)
  8. {
  9. char ch;
  10. if(!read(fp, ch)) return false; // end-of-file
  11. buf.clear();
  12. do {
  13. if(ch == delim) break;
  14. buf.push_back(ch);
  15. } while(read(fp, ch));
  16. return true;
  17. }
  18. //----------------------------------------------------------------------------
  19. } // namespace