Hi Folks,
Why some methods that write bytes/chars to streams takes int instead of byte/char??
Someone told me in case of int instead of char:
because char in java is just 2 bytes length, which is OK with most character symbols already in use, but for certain character symbols (chines or whatever), the character is being represented in ...
I'm used to the Delphi VCL Framework, where TStreams throw exceptions on errors (e.g file not found, disk full). I'm porting some code to use C++ STL instead, and have been caught out by iostreams NOT throwing exceptions by default, but setting badbit/failbit flags instead.
Two questions...
a: Why is this - It seems an odd design decis...
Hi Folks,
I am new to C, and want to read some data from a file.
Actually, I find many reading functions, fgetc, fgets, etc..
But I don't know which one/combination is the best to read a file with the following format:
0 1500 100.50
1 200 9
2 150 10
I just need to save each row above into a struct with three data members.
I...
I'm using C++Builder, and am trying to slowly migrate code to using C++ standard library in preference to the Delphi VCL.
The VCL has a streaming architecture based around the TStream class, and I'm switching to using std::stream instead. However, in the short term, I still need a way of 'mixing' use of the two stream types.
I can do ...
I am using the open4 gem and having problems reading from the spawned processes stdout. I have a ruby program, test1.rb:
print 'hi.' # 3 characters
$stdin.read(1) # block
And another ruby program in the same directory, test2.rb:
require 'open4'
pid, stdin, stdout, stderr = Open4.popen4 'ruby test1.rb'
p stdout.read(2) # 2 characters...
Hi All,
I had a quick question regarding the datacontractserializer. Maybe it's more of a stream question. I found a piece of code that writes the xml to a filestream. I basically don't want the file and just need the string output.
public static string DataContractSerializeObject<T>(T objectToSerialize)
{
var fs = new ...
Hi,
I have a C++ code that has a lot of functions which receives ostream as argument.
I now want to string manipulate the content of this ostream. For example, I want to replace all occurrence of certain word with other word.
The actual parameter to these functions is always ofstream. Is there a way to change the creation of this ofstr...
Hi all,
I have come across a situation (on Win32) where the std::ostringstream object continues to consume process memory, even when it is ostensibly cleared out after a series of append-type operations. Please take a look at this C++ fragment:
int main(void)
{
std::ostringstream cOutputLogStream;
// Random long string
std...
Given:
MY_CLASS* ptr = MY_CLASS::GetSomeInstance();
What is the correct way to output ptr to std::cerr, so I can log its value? Note I don't want to write the class, just the address.
...
Possible Duplicate:
Are there binary memory streams in C++
Oops - http://stackoverflow.com/questions/1559254/are-there-binary-memory-streams-in-c
...
I have a std::istream which refers to matrix data, something like:
0.0 1.0 2.0
3.0 4.0 5.0
Now, in order to assess the number of columns I would like to have some code like:
std::vector<double> vec;
double x;
while( (...something...) && (istream >> x) )
{
vec.push_back(x);
}
//Here vec should contain 0.0, 1.0 and 2.0
where the...
I'm writing an application that creates catalogs of files. Currently the catalog information is stored in an XML file, but I'm trying to abstract the interface to a catalog to allow for other future storage mechanisms such as a single ZIP file, SQL server, or HTTP server. So rather than returning a file path the abstract Catalog class re...
I have started a process in my Java code, this process take a very long time to run and could generate some output from time to time. I need to react to every output when they are generated, what is the best way to do this?
...
I'm having trouble closing my socket when exiting my Java application. I thought that an easy way to make sure the socket gets closed is to hook it on windowClosing in a Swing JFrame like this:
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
input.close();
out...
Hi All
I would like to read some data from a stream I have using std::getline.
Below a sample using the std::cin.
std::string line;
std::getline( std::cin, line );
This is a blocking function i.e. if there is no data or line to read it blocks execution.
Do you know if exists a function for checking data availability before calling s...
So I'm working through a bit of a problem, and some advice would be nice. First a little background, please excuse the length.
I am working on a management system that queries network devices via the TL1 protocol. For those unfamiliar with the protocol, the short answer is that is is a "human readable" language that communicates via a ...
In the example below, what exactally is the << operator doing? I'm guessing it is not a bitwise operator.
std::cout << "Mouse down @ " << event.getPos() << std::endl;
I understand what the code will do here: Use standard out, send this text, send an end of line. Just I've never come accross the use of this << apart from on raw binary....
Hello all,
I want to perform I/O operation in c++. I want to store a pointer to fstream object and using that same fstream I want to read and write to that file. Is it possible without using two different objects i.e ifstream for reading and ofstream for writing.
...
I've got this (incorrect) sample code for getting a value out of stringstream and storing it in a byte-sized variable (it needs to be in a single byte var, not an int):
#include <iostream>
#include <sstream>
using namespace std;
int main(int argc, char** argv)
{
stringstream ss( "1" );
unsigned char c;
ss >> c;
cout ...
Hi, I want to excecute a tail command in Unix for indefinite time and capture its output in a Perl script, process it and store certain data into a database. But it should be live, meaning old data – once stored in the database – shouldn't be reprocessed. It should only capture, and process only the most recent output.
Can someone pleas...