Need byte-splitter utility

From: Fred Cisin <cisin_at_xenosoft.com>
Date: Tue Apr 1 12:16:49 2003

On Mon, 31 Mar 2003, Bruce Lane wrote:
> Yes, it is harsh, and such a statement is of absolutely no use
> to me since there are plenty of other things I have chosen to devote
> my time and energy to.

OK
Sorry, some of us forget that not everybody enjoys programming.
If you have a K&R compatible C compiler, here's a quick, crude one for
you. For some compilers/OS's the "rb" and "wb" need tobe "r" and "w".
IF each of the output files is half the size of the input file, then it
worked.
If you want input of the filenames, better error checking, verification of
file content, etc., that can be added later.

#include <STDIO.H>
#include <FILE.H>

main()
{
        int x;
        FILE * FPIN, FPO1, FPO2;
        FPIN = fopen("INPUT.DAT","rb");
        FPO1 = fopen("OUT1.DAT","wb");
        FPO2 = fopen("OUT2.DAT","wb");
        
        while ((x = fgetc(FPIN)) != EOF)
        {
                fprintf(FPO1,"%c",x);
                x = fgetc(FPIN);
                fprintf(FPO2,"%c",x);
        }
        fclose(FPIN);
        fclose(FPO1);
        fclose(FPO2);
}
Received on Tue Apr 01 2003 - 12:16:49 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:35:41 BST