[net.micro.amiga] sprintf arg lengths limitation

fnf@unisoft.UUCP (11/25/85)

/*
 *	This program demonstrates that there is a limitation on how long
 *	a string "sprintf()" is capable of printing.  On my machine, it
 *	appears to be 200 characters.  I don't know whether this is the
 *	limit on an individual argument, or the total of the argument
 *	lengths, but it would be easy enough to write another test program
 *	to find out.  So, beware..., this has already bitten me once.
 *
 *	Also, note that when the limit is reached, sprintf returns a value
 *	one greater than the actual number of characters placed in the
 *	output buffer.
 *
 *			Fred Fish
 */
 
#include <stdio.h>

#define MAXSIZE (256)

main ()
{
    auto char buffer1[MAXSIZE+1];
    auto char buffer2[MAXSIZE+1];
    register int index;
    register int xfered;

    buffer1[0] = 0;
    buffer2[0] = 0;
    for (index=0; index < MAXSIZE; index++) {
	xfered = sprintf (buffer1, "%s%c", buffer2, '0' + (index % 10));
	printf ("%3.3d: %s\n", xfered, buffer1);
	fflush (stdout);
	strcpy (buffer2, buffer1);
    }
}