#include #include #include void foo (char *buf, int num) { while (num--) strcat (buf, "f"); } int main() { srand (getpid ()); while (1) { int num = rand () % 1024; char *buf = malloc(num); foo (buf, num); printf ("%d, %p, %s\n", num, buf, buf); free (buf); } }