All Questions
1,311
questions
-1
votes
0
answers
18
views
how to redirect absl logs in a pybinded C++ from the calling Python module [closed]
I have a Python binary that leverages numerous C++ functions through pybind11.
Both in Python and C++ I'm using absl logging.
I am trying to setup absl in Python to wrote logs to file instead of ...
-1
votes
1
answer
58
views
How to read from curl into a string stream in C++?
I'm working with a Web API, reading text data to be processed later. Sometimes the data is rather large, like 90 MB. I'm trying to read it into a std::stringstream, so I can get each line later into a ...
1
vote
1
answer
44
views
Is seekg used to offset the input position by zero? If so, why would you do that?
I found the following code at this StackOverflow answer. It reads a file containing floats as binary:
#include <fstream>
#include <vector>
// ...
// Open the stream
std::ifstream is(&...
0
votes
1
answer
28
views
mixing `cout.width` and ios::POSITION
So I am learning streams, and there's an unexpected output when I mix cout.width(20) and cout.setf(ios::left) Take a look at the following code.
cout.width(20);
cout.setf(ios::left);
cout....
0
votes
1
answer
76
views
different buffers yet same address
So I want to quote from the C++ documentation regarding cin.ignore where it states:
it extracts characters from its associated stream buffer object
Now I tried playing around and would like to ...
1
vote
1
answer
55
views
How does the extraction operator ">>" know when to stop extraction?
The question is the same as the title, when using the extraction operator ">>" for the string
" Hello World" There are 3 leading whitespace characters, and after "...
0
votes
1
answer
89
views
Writing bytes in client less than expected [closed]
I'm trying to use a UDP socket in C++ to send data between a client and server as a project in my university. The file I'm trying to send is an HTML document called s.html. It's 1,814,247 bytes in ...
0
votes
0
answers
236
views
Encrypt/Decrypt model files
I have a trained pytorch model that I export using torch.jit.trace(model,input). It saves as a model.pt file. I am able to load the model in c++ (libtorch) using jit::load(). I want to encrypt the ...
-1
votes
1
answer
169
views
C++ std::istringstream how to not terminate at '\0' [closed]
There is a function Foo that takes in an input stream of char. I want to call Foo from my function Bar, which takes in a C-style array with size. char is used to represent a byte (not using std::byte ...
-1
votes
1
answer
125
views
Using a file PATH with a colon in Windows file system
What does the colon in the PATH (for example "a:data.dat") mean in Windows file system.
In the following C++ code:
ofstream outfile;
outfile.open("a:data.dat");
I'm using Windows ...
9
votes
1
answer
253
views
Weird behavior in Visual C++ in reading stream to a double
I am encountering a weird issue in visual studio 2022 (version 17.7.1). In the following program:
#include <iostream>
#include <sstream>
using namespace std;
int main()
{
...
0
votes
1
answer
73
views
How to use ofstream as a part of struct - arg of function
I am trying to use ofstream, opened in function getlog() in function WriteLine(). I have a structure named LOG:
struct LOG {
wchar_t logfile[PARM_MAX_SIZE];
std::ofstream* stream;
};
which is ...
0
votes
0
answers
52
views
How is the `end-of-stream iterator` Created?
I have the code that reads content of 2 files into 2 std::string variables. There is the assign member function used. There are InputIt first and InputIt last passed into it. InputIt first gets a file ...
-1
votes
1
answer
319
views
Writing to the stream buffer of a string stream overrides the previous data
What I want to do is to create string stream , and output stream, giving the buffer of string stream to output stream, so that it will output data to the string stream. Everything seems fine, but ...
0
votes
0
answers
300
views
Simple pipeline architecture
I am trying to make sense of the following answer:
For example you may have a Source interface and a Sink interface - and
a Filter abstract class that implements both Source and Sink, as well
as a ...