Strange C Program
Peter J. Holsberg
pjh at mccc.UUCP
Thu Feb 25 09:53:57 AEST 1988
The following program compiles with no problems. When run by a user, it
generates "EMT trap - core dumped" message, but when run by ROOT, it
works like a charm! Help!!
=========================
#include <stdio.h>
#define MOD 65536
#define MULT 25173
#define ADD 13849
/* This program, named CREATE ,creates pseudo random numbers and sends *
* them to a file named RANDOM. */
main()
{
int n,seed,fseed, i=1;
FILE *fopen(), *of;
of = fopen("random", "w");
printf("\nHow many random numbers would you like to create?\n");
scanf("%d", &n);
printf("\nWith what number would you like to start the ");
printf("pseudo number generator?\n");
scanf("%d",&seed);
while(i++ <= n)
{
seed = seed * MULT + ADD % MOD;
fseed = seed % 100000;
printf("%11d",fseed);
fprintf(of, "%11d",fseed);
}
}
--
Peter Holsberg UUCP: {rutgers!}princeton!mccc!pjh
Technology Division CompuServe: 70240,334
Mercer College GEnie: PJHOLSBERG
Trenton, NJ 08690 Voice: 1-609-586-4800
More information about the Comp.lang.c
mailing list