stdio_getline.cpp 546 B

123456789101112131415161718192021222324252627282930
  1. #include<__vic/stdio_file.h>
  2. #include<__vic/error.h>
  3. #include<iostream>
  4. #include<exception>
  5. #include<cassert>
  6. void run_tests()
  7. {
  8. __vic::stdio_file file("stdio_getline.cpp", "r");
  9. if(!file.is_open()) throw __vic::exception("Cannot open file");
  10. std::string buf;
  11. buf.reserve(4096);
  12. while(__vic::getline(file, buf))
  13. std::cout << buf << '\n';
  14. }
  15. int main()
  16. {
  17. try
  18. {
  19. run_tests();
  20. return 0;
  21. }
  22. catch(const std::exception &ex)
  23. {
  24. std::cerr << ex.what() << '\n';
  25. }
  26. return 1;
  27. }