PADDER.C Tony Lawrence:
A simple C program that pads text files to fixed length records. Was at one time very useful; is probably not today, but who knows?
I wrote this because I needed to bring some files into Filepro as fixed length fields.
It was written on Microsoft DOS, but will compile on Linux (though not on OS X - missing "fcloseall").
Usage: PADDER INFILE OUTFILE PAD-SIZE
if (argc < 3) help(argv);
if (argc == 4)
if (width < 1)
fprintf(stderr,"Can't open %s for input\n",argv);
fprintf(stderr,"Can't open %s for output\n",argv);
if ((mwidth=strlen(bb)) > width )
if (++warning == 1)
fprintf(stderr,"\007Warning: Input width exceeds %d\n",width);
fprintf(stderr,"Input line %5d , truncated %3d chars:\n %s\n",line,mwidth-width,bb+width);
if (mwidth > maxwidth)
fprintf(stderr,"(Max input width was %d)\n",maxwidth);
fprintf(stderr,"Usage:\n%s input-file output-file [pad-size]\n",name);
fprintf(stderr,"[pad-size] defaults to 100\n");
Got something to add? Send me email.
Increase ad revenue 50-250% with Ezoic
More Articles by Tony Lawrence
Find me on Google+
© 2011-04-25 Tony Lawrence