Hi all, I've got a class which I would like to hold a stream used for logging. The stream should be able to be set (and possibly reset) after the construction of the object. It should be possible to set the stream as std::cout, or as a file stream to log to a file, or as a stringstream which does nothing more than ignore the data (a /dev/null of sorts). In any case, it should be an ostream type object, which the creator of the object can reset at any time. The class itself is oblivious to the concrete stream …

Member Avatar
Member Avatar
+0 forum 4

what is the use of [code]unix-stream("path/to/file");[/code] I can't seem to find it anywhere.

Member Avatar
Member Avatar
+0 forum 1

I was using getline() function and it was getting skipped. I searched through the forum and found the tutorial on how to flush the input stream but there is one thing that is still unclear to me : getline() uses newline character as a delimiter. So when a '\n' is found at the end in input stream getline() is skipped. As stated in the tutorial, formatted stream leaves a newline character in the stream and the mixed/non-formatted one consumes it. So shouldn't getline be skipped in formatted stream rather than in non-formatted one?? P.S : I would've posted in the …

Member Avatar
Member Avatar
+0 forum 3

Hi all, I am trying to create a class to serve as a customized cout class. Right now I have made some test code to see if I can do it. Right now I am trying to make it function just like cout, but later I will have it do more than just print text to the screen. Currently my class works when I try and print one item, but not multiple ones. The code: [CODE=c++, operator.cpp]#include "operator.h" using namespace std; void printclass::operator<<( const string & mesg ) { cout << mesg; } int main() { printclass print; print << …

Member Avatar
Member Avatar
+0 forum 2

I've found some similar posts on opening different files with the same file stream but they are difficult to understand. I'm trying to figure out for a larger project why I can't use the same file stream as in this example and what an alternative solution may be. And yes I am aware that this example opens the same file twice. [CODE] #include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line;ofstream thefile; thefile.open ("example.txt"); thefile <<"writing this to a file. \n"; thefile.close(); ifstream myfile ("example.txt"); if (myfile.is_open()) { while (! myfile.eof()) { getline (myfile, …

Member Avatar
Member Avatar
+0 forum 3

Hi everyone I'm working on a remote controled robot which have four cams & one sound recorder. the robot encode the data send it to a computer, an application decode data and view 4 cams & play sound. Here is my question is there any function or library than can help with 4 video streams? any advise? I need your help, tnx so much

Member Avatar
Member Avatar
+0 forum 4

Hi All, I have a section of my site that allows users to upload and download files. For security issues, We use a com object to take the file as a binary stream and store it on our network off of the web server (under a different randomly generated file name). The same com object is used to stream the file back to the user if they open the link to it so they never know where the actual file is stored. Everything was fine with this until we upgraded to Office 2010 now docx and xlsx files are uploading …

Member Avatar
Member Avatar
+0 forum 2

Hey friends.Need a help from you again. I'm trying to study about streams and I wrote small code for get input from command line and print it in the screen,but It prints weird characters like Japanese :O . Can anyone explain what I did wrong... [CODE] import java.io.*; public class ReadBytes { public static void main(String[] args) { try{ // FileInputStream file =new FileInputStream(System.in); BufferedInputStream buff = new BufferedInputStream(System.in); DataInputStream data = new DataInputStream(buff); int count=0; try{ while(true){ char input =data.readChar(); System.out.print(input+" "); count++; } } catch(EOFException eof){ buff.close(); } System.out.println("\nBytes read: " +count); }catch(IOException e){ System.out.println("Error -- "+e.toString()); } …

Member Avatar
Member Avatar
+0 forum 10

Hey, I'm working on a project where we have to stream files from a server app to clients. I have it all working nicely, but we have a special client type that cannot save files to HDD, not even temporarily. I can get the byte stream from server to this special client, so only the data handling in the client side is the problem. I was thinking, is there any way to open the streamed files in the client app without saving them first? For example, if I send a .JPG file from server to client, how can I open …

Member Avatar
Member Avatar
+0 forum 7

Hi there. I'm trying to write a program that will establish a DB of names and Ids. The thing is i don't want to scan the entered data to a temporary variable and then put it into the file, but to scan the user's input directly to the file itself. Is there any way to do so? If not, what is the most efficient (memory-wise) way to get user's input into the file? char by char? Thanks!

Member Avatar
Member Avatar
+0 forum 4

Hi I'm writing a site that allows users to download documents securely stored on the network off of the web server. I'm using a com object on the server that we've been using here for ages that fetches the file from the network in a binary stream thus preventing user access to the network. The problem I'm having is when the user clicks on the link, instead of the file opening, the page reloads itself with the stream as its source. On the open save dialog instead of filename.* I get MyPage.aspx as the file name it is as if …

Member Avatar
Member Avatar
+0 forum 1

Hi me again! =) if you didn't already know i am making a simple HTTP Server using TCP/IP sockets for a project. i have a method to get an image and send it over to the browser but i am having problems doing so, i have tried doing it different ways but nothing seems to be working. the browser asks for the image, the server sends the head along with the image but the browser never shows the image. the server works fine for all the html/css files i have send to the browser. Please help me!!! oh and yess …

Member Avatar
+0 forum 0

Need a little help, I'm trying to run a program that asks the user to enter an integer between 1-50. If given a number between 1 and 50 then echo number then add all integer between 1 and integer entered if user enter an integer not between 1 and 50 then just echo the number and ask the user for another number if a noninteger is enter i need the program not to go into and fail state, instead clear the noninteger and ask the user for another integer. To exit the loop you must press cntl-Z. This is what …

Member Avatar
Member Avatar
+0 forum 1

I have been stuck on this problem for a while, and I just can't figure it out. I'm sure there's an incredibly easy way to do it, but I'm at a loss... I need to take in this text file: Smith, M.N., Martin, G., Erdos, P.: paper name Erdos, P., Reisig, W.: paper2 name Smith, M.N., Chen, X.: paper3 name Jablonski, T., Hsueh, Z.: paper4 name Hsueh, Z. Chen, X. Smith, M.N. The problem I have is that I can't get the file input right. I need it to stop at the ':', because the name of the paper isn't …

Member Avatar
Member Avatar
+0 forum 4

I have a text file with the following numbers: 1 2 3 4 5 6 How do I read each individual number into an array? It needs to move along each row so read in 1, 2 and then 3 into a array of 6 integers. Then move to the second row and read 4 5 and 6... Thank You

Member Avatar
Member Avatar
+0 forum 2

This is for the numerous people I see constantly asking how to "pause" the console after their code runs. The explanation for how the code works is within the snippet in comments. Basically, the "cin.clear();" function will clear the input stream, getting rid of any newline characters that would have made methods like using the "cin.get();" function to pause the console not work. Then, we have the "cin.ignore();" function. This will ignore the maximum amount of characters that can be entered into the stream (numeric_limits<streamsize>::max) be ignored, or wait for a newline character ( \n ). This way, the console …

Member Avatar
Member Avatar
-1 forum 10

Hi.. This is my first time posting here, so i hope u can assist me. I have this code [CODE]<% '======================= 'Define the names of your functions '======================= Dim Stream Dim Contents Dim FileName Dim FileExt 'Const adTypeBinary = 1 '======================= 'Get the actual file name from the URL that is passed to the browser '======================= FileName = request.form("fname") 'Get the name from the URL '======================= 'GIVE AN ERROR MESSAGE IF THE URL IS EMPTY '======================= if FileName = "" Then response.write "Filename Not specified." response.end end if '======================= 'prevent access to certain files '======================= FileExt = Mid(FileName, InStrRev(FileName, ".") …

Member Avatar
Member Avatar
+0 forum 1

Hi everyone, i was wondering how it might be possible to send variables from a programme written in c++ to be used in a separate application which is coded in python. I am using opencv to calculate points of interest in c++. I would then like these resulting co ordinates to be sent to a game engine (blender game engine) to be assigned to specific objects. I have no experience using python and have never written a C++ program that would need to transmit data in such a fashion. I've been researching possible solutions but I'm unsure of what the …

Member Avatar
Member Avatar
+0 forum 2

[CODE]int main2() { cin.get(); cin.ignore(); cin.clear(); while(true) { long double x, y; char ch_op; Sleep(200); cout << "Enter an expression below: \nExamples:\n"; cout << "x + y for Addition.\nx * y for Multiplication.\n" << "x / y for Division\nx - y for Subtraction.\nx & x for Square Roots.\n" << "x ^ y for Exponential Functions.\n\n"; cin >> x >> ch_op >> y; switch(ch_op) { case '+': { add(x, y); main2(); break; } case '-': { subtract(x, y); main2(); break; } case '*': { multiply(x, y); main2(); break; } case '/': { divide(x, y); main2(); break; } case '&': {cout << …

Member Avatar
Member Avatar
+0 forum 5

This handy function turns file into stream of words stripped of punctuation, whitespace and digits, but does not split for example we'd to two words. If you want that you can further process yielded words or change the definition.

Member Avatar
Member Avatar
+3 forum 5

Hello guys, this is my first post, so don't be harsh if I do something stupid. Well, the reason why I'm posting here is because I need to find a method to alter the stream itself, not just the buffer I send to a variable with "file.Read(". For example, lets say i have a file whose bytes are as follows: 05 FF 3E 23 80 BD As I'm using MFC I'd use 'file.Open' to open the file, and 'file.Read' to send the stream above to a buffer (char *) variable. What I want to do is to change the stream …

Member Avatar
Member Avatar
+0 forum 5

Hello all, I have a text file called: concentrations.dat The file contains a lot of different data. Here's the data that I'm interested in: # ET: list of elements <ET> 'Cu' 'C' 'Sr' 'He' 'Mg' 'O' 'Cr' What I want to do is read the elements into a vector called elementVector. So I would end up with Cu, C, Sr, He, Mg, O, and Cr as elements of the vector without the ' symbols. Can anyone tell me how to do this? An example would be much appreciated. I have had no success with using ifstream. I can read in …

Member Avatar
Member Avatar
+0 forum 2

Hello there, What would be a simple way to stream a file from a url?

Member Avatar
Member Avatar
+1 forum 3

Hi, I make an application in java ME (client) that connects to a PC application (server) using OBEX protocol. Connection goes well but I don't understand why I can use the stream to send JUST one message frmo the client and after that I must close the stream to see the message at the server. I have these codes: SERVER (PC) [CODE] public void startServer() throws IOException{ LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC); serverConnection = (SessionNotifier) Connector.open("btgoep://localhost:" + serverUUID + ";name=ObexExample"); handler = new RequestHandler(); System.out.println("waiting for clients..."); serverConnection.acceptAndOpen(handler); System.out.println("Received OBEX connection "); } String serverUUID = "123"; Operation operation; DataInputStream dis; InputStream is; private …

Member Avatar
Member Avatar
+0 forum 1

I have a csv file that has 12 columns. I've been using: [code=c++] while(!infile.eof()) { getline( infile, source, ',' ); outfile << source << ", "; getline( infile, native_ID, ',' ); outfile << native_ID << ", "; getline( infile, index, ',' ); outfile << index << ", "; getline( infile, charge, ',' ); outfile << charge << ", "; getline( infile, cluster_ID, ',' ); outfile << cluster_ID << ", "; getline( infile, fdr, ',' ); outfile << fdr << ", "; getline( infile, precursor_mass , ',' ); outfile << precursor_mass << ", "; getline( infile, calculated_Mass, ',' ); outfile << …

Member Avatar
Member Avatar
+0 forum 1

This is as much of a question about algorithm as it is about code. I’m training monkeys to input data into a keyboard in the form of a table. I have created a special keyboard with nothing on it but numbers 0 - 9, a period, tab key and a return key. The goal is to get them to input data in rows and columns. However, I have been unsuccessful so far, as I am unable to get them to input a consistent number of columns. The input I get looks like this: 443 3439 3.932 4 55 9.99.9 12 …

Member Avatar
Member Avatar
+0 forum 4

A most basic TCT connection is established with the code below: [CODE]// Initialization IPEndPoint m_IpEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.71"), 5000); Socket m_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); NetworkStream m_Stream = new NetworkStream(m_Socket); // Read/write operations m_Stream.Write(System.Text.Encoding.ASCII.GetBytes("Hello world!"), 0, 12); byte[] read_buffer = new byte[4096]; m_Stream.Read(read_buffer, 0, 4096); // Closing open resources m_Stream.Close(); m_Socket.Shutdown(SocketShutdown.Both); m_Socket.Close();[/CODE] When communicating through TCP we specify both local and foregn sockets, right? Correct me if I'm wrong, this is my first network program. I want to ask these question: What does "127.0.0.71:5000" specify in my code? Is it local or foreign socket address? If it is local, …

Member Avatar
Member Avatar
+0 forum 8

Hi, I'm trying to capture an audio stream from Axis IP camera. The audio data encoded as g.711 should be captured from the camera. I'm using the following http request: [code] Stream roughStream = null; string URLaudio = "http://5.123.220.228/axis-cgi/audio/receive.cgi?httptype=singlepart"; request = (HttpWebRequest)HttpWebRequest.Create(URLaudio); request.Credentials = new NetworkCredential("admin", "password"); request.Method = "GET"; audioResponse = (HttpWebResponse)request.GetResponse(); roughStream = audioResponse.GetResponseStream(); [/code] However, I am getting that audioResponse has ContentLength equal to -1, (meaning that either I'm not getting the data at all, or it cannot read the stream beacuse of something (stream too long?!?). I am guessing that camera is sending a continuous stream …

Member Avatar
Member Avatar
+0 forum 2

Greetings, I'm working my way through the Head Start C# book, and I know that whenever I open a stream [CODE=c#]Stream reader = File.Open(filename));[/CODE] I [B][I][U]ALWAYS[/U][/I][/B] [CODE=c#]reader.Close();[/CODE] my stream. The book also lets you know you can use a using block [CODE=c#]using (Stream ...) { }[/CODE] and the stream will be closed at the end of the block. So I find myself working happily through the material covering exceptions, and I know that in a try, catch, finally block, the code in 'try' is executed, and if a exception is encountered, the execution jumps to 'catch', runs, and then the …

Member Avatar
Member Avatar
+1 forum 3

I'm am trying to send over socket a very big array - length about 1300000 .... and I use ObjectInputStream and ObjectOutputStream. The problem is when I read the input stream... I get this exception: java.io.StreamCorruptedException: invalid type code: FF at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1356) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at objectThread.run(objectThread.java:27) [CODE] //ois is the ObjectInputStream //o is an Object while (ois != null && (o = ois.readObject()) != null) // here I got the exception { System.out.println("while entered..."); int[] r = (int[]) o;//get the array } [/CODE] Is the array to big? Or how can I send it over network in the most reliable …

Member Avatar
Member Avatar
+0 forum 4

The End.