Skip to content
Prev 168027 / 398502 Next

Write to multiple connections or multiple text files

On Fri, 23 Jan 2009, Andersson, Jafet wrote:

            
If you know 'n' before opening the connection or can easily figure it out 
using the system's grep command (on your linux side), you would probably 
be best off using two calls to the system() function along with your 
system's head, cat, and tail functions to copy the parts you do not alter 
to a temp file. Using pipe() with the system's head and tail commands you 
pick off the line you modify and cat() to append it in between the 
system() call that copies what preceeds it and and the call that copies 
what succeeds it. Once the temp file is complete, you replace the orignal 
with it.

HTH,

Chuck
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901