FILE* and streams

Posted on 2004-08-30
Last Modified: 2010-04-01
Hello all,
   I'm making use of a static library that makes use of stdout and stderr as input to different functions that require a FILE* as a parameter.  I would like to make use of these functions, but do not want to create a temporary, ( or permanent for that matter ), file on the drive to make use of the functions.  What can I do to pass a stream into this function so that I can read the output from the function?

Thanks much.
Question by:edc
  • 2
  • 2
LVL 22

Expert Comment

ID: 11936100
You could use a pipe.  Depending on the OS, it could be as simple as opening a file named "\\.\\pipe\\MyPipe".


Author Comment

ID: 11936143
Hi grg99.  The OS is windows, (most likely 2K, XP and 2003, but could also be 9x).  Would the pipe work on the Windows OSs?

Thanks much.

Author Comment

ID: 11936149
Also, if so, where can I find documentation on how to use it?

Thanks again.
LVL 16

Expert Comment

ID: 11940884
Of course you can use pipes on Windows. Take a look here
LVL 22

Accepted Solution

grg99 earned 125 total points
ID: 11941289
Note that pipes are kinda shaky-- the semantics of multiple pipe readers are very fuzzy.  Also Windows 95/98 are only half-assed-- they can be pipe clients but not servers.  Yet another intentional cripling, thanks MSoft.

I'd try using a temporary file, much easier and works on all OS's.


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Template syntax for variable length arrays 9 71
Grammars for C C++ and java 1 114
Unresolved External Symbols 3 68
computer science syllabus 3 70
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now