Category : file-io

So I’ve got a >> overload set up that pulls labels and chunks of text (images) from a file: friend std::istream& operator>>(std::istream &is, Image data) { std::string line; std::string full_image; getline(is, line); data.SetLabel(line); for (size_t i = 0; i < data.GetImageSize(); ++i) { // Stores each full image as a single string getline(is, line); full_image ..

Read more

So, I need to be able to parse a file full of integers line by line (putting each number in an array). The reason is that I’ll be sorting each line of numbers. When I try checking for a ‘n’, I’m not getting the proper results. The first number of each line tells me the ..

Read more

I have an 970 EVO Plus NVMe M.2 SSD 2TB installed on a centos 7 Machine. Using the following code I get strange stalls: #include <fmt/core.h> #include <string> #include <fstream> #include <vector> #include <chrono> #include <cassert> #include <cstdint> template<typename T> void manual_buffered_record(std::ostream& ostream, T* new_data, std::size_t new_data_size){ auto start = std::chrono::high_resolution_clock::now(); static std::vector<std::byte> buffer; static ..

Read more

It keeps throwing the error message: "Error verifying file: Unable to open output file for verification: No such file or directory" What am I doing wrong? #include "FileModifyException.h" #include <cerrno> #include <errno.h> #include <cstring> #include <iostream> #include <unistd.h> #include <fcntl.h> #include <sstream> #include <util.h> using namespace std; void Part1SimpleFileModifier::modifyAndCopyFile(const char *sourceFile, const char *destFile) { ..

Read more

I am trying to read words from a dictionary file whose filename is provided by the user. The program does open the file properly, but upon an attept to getline() the program sees nothing. I’ve had success with getline before but this is confusing me. #include <iostream> #include <fstream> #include <string> int main() { cout ..

Read more