I recently heard of a C++ function called piping - sending a .txt to an .exe. I Couldn't find anyonr that knew how to do it. If someone does - could they post a basic version of it? thanks.
I recently heard of a C++ function called piping - sending a .txt to an .exe. I Couldn't find anyonr that knew how to do it. If someone does - could they post a basic version of it? thanks.
I've never heard of a specific C++ process of piping that has to do with sending a .txt to a .exe, but that doesn't mean there is one.
The term piping simply means to pass data through a function or process and get a result. Think back at algebra where you pass the domains of a function through the function to get the range.
So to say that you want to "send a .txt to a .exe" with the term piping in the same sentence, only leads me to ask, what do you want the .exe to do to the .txt? Regardless of the answer to this question, you'll inevitably start off looking at File I/O. There is a section in the Cprogramming.com tutorials on this. You could also search <fstream> on the web.
Sent from my iPadŽ
"Piping" usually refers to sending data from one process to another so that the standard output of one process (cout) is connected to the standard input (cin) of the other one. This connection is graphically visualised as a "pipe" between the two processes, hence the name. This isn't C++ specific; you can pipe data between programs written in any language. http://en.wikipedia.org/wiki/Pipeline_%28Unix%29
For example, to pipe the contents of 'file.txt' to program 'program' you could give the command "type file.txt | program" ('type' is the command in DOS to type out a file) If 'program' is written in C++ it would be able to read file.txt from "cin".
stdin and stdout are the terms you should be using there. Those are what would refer to your standard input and output in any language and system. I mention this because you could never read file.txt from "cin" (unless some wise ass wanted to cin a string that says "file.txt"). You're also being slightly close minded about the idea of piping. Yes, there are standard methods of piping in commands windows and certain programming languages (usually using the pipe '|' character), but if a person were to write a program that took a file and replaced all spaces in it with commas, that could be viewed as a pipe, as well. It takes input, passes it through a function or process, and outputs the result.
Sent from my iPadŽ
You don't consider the example that I gave as "reading file.txt from cin" ?I mention this because you could never read file.txt from "cin"
I admit it's not really reading the file but rather the content of the file as it is being read and written out by another program. I would consider that as more or less the same thing.