My omnium-gatherom of scripts and source code.
at main 45 lines 937 B view raw
1/* ======================================================================== 2 * 3 * Filename: 4 * Description: 5 * Author: 6 * Version: 0.0.1 7 * 8 * ======================================================================== */ 9#include <iostream> 10#include <fstream> 11 12template<typename T> 13using ptr = T*; 14 15template<typename T> 16using ref = T&; 17 18auto count_words(ref<std::ifstream> stream) -> size_t 19{ 20 auto ctr = 0lu; 21 auto ch = '\0'; 22 while (!stream.eof()) { 23 ch = stream.get(); 24 while (ch == ' ') ch = stream.get(); 25 ++ctr; 26 } 27 return ctr; 28} 29 30struct FreqKV { 31 32}; 33 34auto main() -> int 35{ 36 auto file_path = "shakespeare.txt"; 37 auto f = std::ifstream(file_path, std::ios::binary); 38 std::cout << (char)f.peek() << std::endl; 39 std::cout << (char)f.peek() << std::endl; 40 std::cout << (char)f.peek() << std::endl; 41 std::cout << (char)f.peek() << std::endl; 42 // std::cout << "words is: " << count_words(f) << "\n"; 43 return 0; 44} 45