Dallas G on Thu, 05 Jun 2003 11:01:56 +0200 (SAST)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Linux dev] Re: [C] One file pointer to write to 2 files


Title: RE: [Linux dev] [C] One file pointer to write to 2 files
Hi,
 
why not write one file, and exec a shell command to copy the file, that way the os handles execution,
as always i stand to be corrected
 
Dallas
----- Original Message -----
Sent: Thursday, June 05, 2003 10:59 AM
Subject: [Linux dev] Re: [C] One file pointer to write to 2 files



> > In C can I associate a single file pointer to 2 output
> files. I.e. I want to
> > write the same data to 2 different files. The "dup" and
> "dup2" function
> > calls allows one to duplicate a file pointer to a single
> destination. Or am
> > I missing the plot here?
>
> Not quite... :)
>
> No, I don't yet know of a system call method to do it, but if
> you "have to"
> I faked it before with a FIFO + the GNU utils' tee, though that was
> only in appending mode.
>
> Perhaps why do you want it and what do you ned to achieve?
>

Hi,

Basically, I want to write the same data to 2 files.

It seems rather tedious to have to do this:

fprintf(fp1,"data....");
fprintf(fp2,"data....");

everytime. The data is exactly the same.

There are a couple of hundred places where this needs to happen.

I'm sure I can cook up something messing with a new FILE* type.
Just wanted to know if there was some other standard function I am unaware of.

Thanks and regards.

Nimish