Is it possible to send data to another C++ program, without being able to modify the other program (since a few people seem to be missing this important restriction)? If so, how would you do it? My current method involves creating a temporary file and starting the other program with the filename as a parameter. The only problem is that this leaves a bunch of temporary files laying around to clean up later, which is not wanted.
Edit: Also, boost is not an option.
Clearly, building a pipe to stdin is the way to go, if the 2nd program supports it. As Fred mentioned in a comment, many programs read stdin if either there is no named file provided, or if
-is used as the filename.If it must take a filename, and you are using Linux, then try this: create a pipe, and pass
/dev/fd/<fd-number>or/proc/self/fd/<fd-number>on the command line.By way of example, here is hello-world 2.0: