Looking for sample code to merge two files.

Looking for sample code to merge two files.

Post by Alan Boot » Tue, 15 Apr 1997 04:00:00



I'm looking for sample code that merges two files.  Code or location
would be appreciated.

Thanks,

Alan
--

Ratheon/E-Systems
7700 Arlington Boulevard
Falls Church, VA 22046

 
 
 

Looking for sample code to merge two files.

Post by cliff johnso » Wed, 16 Apr 1997 04:00:00



> I'm looking for sample code that merges two files.  Code or location
> would be appreciated.

ummmm, merge 2 files?

could you be a little more specific?

I mean 'cat file1 file2 > file3' will merge two files, but that
is probably not what you mean. :)

cliff

 
 
 

Looking for sample code to merge two files.

Post by sean wal.. » Wed, 16 Apr 1997 04:00:00



> I'm looking for sample code that merges two files.  Code or location
> would be appreciated.

Merges how?  If you're talking about concatenation, how about:

        void (FILE* OutFile, FILE* In1, File* In2)
        {   int c;

            while ( (c = getc(In1)) != EOF )
                putc(c, OutFile);
            while ( (c = getc(In2)) != EOF )
                putc(c, OutFile);
        }

If you're talking about scripting, use:

        cat file1 file2 >outfile

If you're talking merge-sort, try:

        cat file1 file2 | sort >outfile
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sean Walton, KB7rfa (Tech+) [name mangled: "swalton" is username]
Intelligent Algorithmic Solutions (IAS)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 
 
 

Looking for sample code to merge two files.

Post by Ove Svensso » Thu, 17 Apr 1997 04:00:00



> I'm looking for sample code that merges two files.  Code or location
> would be appreciated.

> Thanks,

> Alan
> --

> Ratheon/E-Systems
> 7700 Arlington Boulevard
> Falls Church, VA 22046

Try GNU sdiff. Can be found at any good ftp-site that has
GNU software.