I want to write to a std::stringstream without any transformation of, say line endings.
I have the following code:
void decrypt(std::istream& input, std::ostream& output)
{
while (input.good())
{
char c = input.get()
c ^= mask;
output.put(c);
if (output.bad())
{
throw std::ru...
within Qt is it possible to use cin?? I can use cout but cannot find anywhere where it shows how to use ciin within a Qt Console application
many thanks,
gda2004
...
I using readLine() method for reading the text, but i am not aware of how many text can read that method. Ex.
String str = in.readLine();
how many texts can read and store on "str"?
...
I have a problem with with my output when I write to I file I get squares when I put endl to change lines.
std::ofstream outfile (a_szFilename, std::ofstream::binary);
outfile<<"["<<TEST<<"]"<<std::endl;
I get something like this in my file plus the other outputs don't write on the next line but on the same one.
[TEST]square
appa...
I need to prevent my double to print in scientific notation in my file,
when I do this
outfile<<X;
...
I'm writing a lambda calculus interpreter for fun and practice. I got iostreams to properly tokenize identifiers by adding a ctype facet which defines punctuation as whitespace:
struct token_ctype : ctype<char> {
mask t[ table_size ];
token_ctype()
: ctype<char>( t ) {
for ( size_t tx = 0; tx < table_size; ++ tx ) {
t[tx] = isal...
I've seen people do things like....
istringstream ibuf;
if (ibuf >> zork >> iA >> Comma >> iB)
now I guess the value depends on what >>iB exposes but exactly what is that and what does it mean? Does true mean all the ietms were extracted?
Also, after an expression like
ibuf >> zork >> iA >> Comma >> iB;
is there any way to ...
Why does the following not work:
#include <iostream>
#include <fstream>
#include <stack>
std::stack<std::ifstream> s;
-PT
...
Is it possible to interoperate with a C++ iostream and python? I'm using boost-python and want to wrap a function that has istream and ostream as arguments.
...
I'm trying to update a random-access binary file using the std::iostream interface with separate get/put positions managed via seekg/seekp. Everything works fine with stringstream, but when I create a file descriptor-based stream using Boost.Iostream (specifically boost::iostreams::stream<boost::iostreams::file_descriptor>), the get/put ...
I have a 2884765579 bytes file. This is double checked with this function, that returns that number:
size_t GetSize() {
const size_t current_position = mFile.tellg();
mFile.seekg(0, std::ios::end);
const size_t ret = mFile.tellg();
mFile.seekg(current_position);
return ret;
}
I then do:
mFile.se...
Can anybody explain the difference between cerr cout and clog and why does different objects are proposed?
I know the differences are as below:
1) cout can redirected but cerr can't
2) clog can use buffer.
I am confused about the point 2, I am grateful if anybody can elaborate it more.
...
In the answer to this question ovanes states:
Please be aware that
boost::lexical_cast is much slower as
atoi. I also use it very often in a
performance non-critical code. The
problem with lexical_cast is that it
uses stringstream for conversion. If
you are working in a multi-threaded
environement any stream class from ...
Hi
In such code, what it is called, \\n like this?
cout<<"Hello\\n \'world\'!";
What's the basic rule about such characters?
...
I have an application that wants to read word by word, delimited by whitespace, from a file. I am using code along these lines:
std::istream in;
string word;
while (in.good()) {
in>>word;
// Processing, etc.
...
}
My issue is that the processing on the words themselves is actually rather light. The major time consumer is...
I got some problems with EOF and stdio in a communication pipeline between a python process and a C++ program. I have no idea what I am doing wrong. When I see an EOF in my program I clear the stdin and next round I try to read in a new line. The problem is: for some reason the getline function immediatly (from the second run always, the...
Hi, I'm trying to figure out how to redirect istream to wxwidgets.
I was able to accomplish redirecting ostream, here's how (so you know what I mean):
wxTextCtrl* stdoutctrl = new wxTextCtrl(...);
wxStreamToTextRedirector redirect(stdoutctrl); //Redirect ostream
std::cout<<"stdout -- does this work?"<<std::endl; //It worked.
I'...
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("test.txt");
return 0;
}
fstream is derived from iostream, why should we include both in the code above?
I removed fstream, however, there is an error with ofstream. My question is ofstream is derived from ostream, why fstrea...
I want to read both formatted text and binary data from the same iostream. How can I do that?
Why? Imagine this situation: You have different resources, and resource loaders for them, that take a std::istream as a parameter. And there are a "resource source" that provides these streams. Resources can be both text and binary and I need t...
This might be a repeat, but my google-fu failed to find it.
I want to print numbers to a file using the stl with the number of decimal places, rather than overall precision.
So, if I do this:
int precision = 16;
std::vector<double> thePoint(3);
thePoint[0] = 86.3671436;
thePoint[0] = -334.8866574;
thePoint[0] = 24.2814;
ofstream file...