iostream

Accessing the data / voice streams for the Android and iOS platforms

I haven't done any work with the Android or iOS platforms, but I have recently been pitched a project and I'm trying to see if it is even feasible. Is there currently API hooks in the iOS and Android platforms for accessing / manipulating the voice / data streams? What I would like to do is encrypt all outgoing steams and decrypt all i...

Try to write char[] to a text file

I trying to write a char[256] to a text file. Below is my current work: fstream ofs; ofs.open("c:\\myURL.txt"); ofs.write((char*)testDest,256); ofs.close(); It still does not work. here is the error: error C2440: 'type cast' : cannot convert from '' to 'char *' update: so far, here is my progre...

Using SQLite with std::iostream

Does someone know a wrapper which would allow SQLite to load its data from an std::iostream? To be more explicit: std::fstream dataStream("database.sqlite"); ... sqlite3_open(...something using dataStream...); I want to use streams because of their modularity: being able to load a file while it is still being downloaded from the netw...

Strange? behaviour of cout.

Why executing this code: // DefaultAny.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> #include <exception> using std::cout; template<class T> struct NoReturnPolicy { static void calculate(T& result, const T& source) { result = source; } }; template<class T...

Are System.out, stdout and cout the exact same thing ?

Are System.out, stdout and cout the EXACT same thing in Java, C and C++ respectively? Why have three different names for the same thing (especially when C, C++ and Java have much in common)? Also, I know what they are used for but what are they exactly, under the hood, I mean? ...

cin skipping in while

Why is my cin being skipped in the following while? int main() { int option; cin >> option; while(!cin.good()) { cout << "Looping" << endl; cin >> option; } } ...

Understanding the design of std::istream::read

std::istream has the prototype istream& read (char* s, streamsize n) the actual number of bytes read should be gotten by calling istream::gcount(), also the validity of the istream can be known from ios::good. I was discussing another stream class' implementation I was trying to write with a colleague of mine, where I was saying I might...

Transparently manipulating strings inserted into an ostream

I'd like to provide an std::ostream that may or may not, from the user's point of view, encrypt its contents. Imagine some random function that uses an std::ostream&: void write_stuff( std::ostream& stream ) { os << "stuff"; } Whether stuff is output in cleartext or is encrypted is dependent on how the stream argument was initial...

StreamWriter not writing out the last few characters to a file

We are having an issue with one server and it's utilization of the StreamWriter class. Has anyone experienced something similar to the issue below? If so, what was the solution to fix the issue? using( StreamWriter logWriter = File.CreateText( logFileName ) ) { for (int i = 0; i < 500; i++) logWriter.WriteLine( "Process co...

Using iostream << to serialize user objects

I want serialize object to binary file using operator "<<", but when I serialize, for example, int fields, I obtained it's symbolic representation: ofstream out("file", ios::out | ios::binary); int i=0xAA; out << i; And output: 0x31 0x37 0x30 i.e. (0xAA -> 170) 170 If I use write function, all ok: out.write((char*)&i,sizeof(int...

Java openStream error

Hello, I am using the method openStream with Java in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8")); How long is the method waiting of a response from the service where the URL is sended? I am becoming same times errors messages like this and i don't know why. java.net.UnknownHostException: dev.virtualearth...

C++ Linker error iostream overloading

i get 2 linker errors when trying to compile my program which includes these two files (causing the problem, in particular the lines in bold) and i'm new to C++ so excuse my ignorance. Assignment1.obj : error LNK2001: unresolved external symbol "public: class Vector __thiscall Vector::operator^(class Vector)" (??TVector@@QAE?AV0@V0@@Z)...

Stitching together multiple streams in one Stream class

I want to make a class (let's call the class HugeStream) that takes an IEnumerable<Stream> in its constructor. This HugeStream should implement the Stream abstract class. Basically, I have 1 to many pieces of UTF8 streams coming from a DB that when put together, make a gigantic XML document. The HugeStream needs to be file-backed so tha...

Should C++ keep variables intact on input failure?

Doesn't C++ offer any guarantee about keeping variables intact on input failure? With older versions of gcc, a program like this one keeps the -1 value of i on failure (for instance if a letter is typed instead of a number on input). With Ubuntu 10.10 (gcc 4.4.5), i is reset to zero in case of input failure. #include <iostream> int mai...

Find all a substring's occurrences and locations

Hello guys, I'm writing a program to parse some data saved as text files. What I am trying to do is find the location of every needle in a haystack. I already can read the file in and determine the number of occurrences, but I am looking to find the index also. Thanks, -Tom ...

client socket sends data but server socket does not receive them. c++ buffered stream!?

I am working on a project where a partner provides a service as socket server. And I write client sockets to communicate with it. The communication is two way: I send a request to server and then receive a response from server. The problem is that I send the data to the server but apparently the server cannot receive the data. From my ...

Fast controled copy from istream to ostream

I have to copy several bytes from a istream to a ostream, there are 2 ways that I know to perform this copy. myostream << myistream.rdbuf(); and copy( istreambuf_iterator<char>(myistream), istreambuf_iterator<char>(), ostreambuf_iterator<char>(myostream) ); I've found that rdbuf version is at least twice as fast as th...

Need Help In Writing To A File

Hi guys, i have the following class that writes to a file but is not working as i want. I call the write method in a while loop so that it writes a string to a new line. It only writes the last string. All the previous ones are not written except the last one. Here is the class: import java.io.FileReader; import java.io.FileWriter; im...