Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <filesystem>
- #include <fstream>
- #include <chrono>
- #include <string>
- #include <vector>
- #include <cctype>
- #define debug(x) std::cout << x << std::endl
- #define error(x) std::cerr << x << std::endl
- #pragma region File Streaming
- const std::string DIRECTORY = std::filesystem::current_path();
- const std::string SOURCE_FILE = "source";
- void ReadFromFile(const std::string& path, std::string& output) {
- std::getline(std::ifstream(path), output, '\0');
- }
- void WriteToFile(const std::string& path, const std::string& data) {
- std::ofstream stream(path, std::ofstream::out);
- if (stream.is_open()) {
- stream << data;
- stream.close();
- } else {
- error("Could not open " + path + ".");
- }
- }
- int main() {
- auto start = std::chrono::high_resolution_clock::now();
- std::string code;
- ReadFromFile(DIRECTORY + "/" + SOURCE_FILE, code);
- for (int i = 0; i < code.size(); i += 1) {
- debug(std::to_string(code[i] == 'e'));
- }
- auto finish = std::chrono::high_resolution_clock::now();
- std::chrono::duration<double> elapsed = finish - start;
- debug("Time: " + std::to_string(elapsed.count()) + " seconds.");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement