Xref: news2.mv.net comp.lang.c:66619 comp.os.msdos.djgpp:3468 From: nmarrone AT smartlink DOT net (Nicholas Marrone) Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Use of random Date: Sun, 05 May 1996 15:51:12 GMT Organization: SmartLink.net Premier ISP 805-294-1273 Lines: 56 Message-ID: <4mikhp$pa5@frodo.smartlink.net> NNTP-Posting-Host: pm42-52.smartlink.net To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Hullo, To test out my radix_bit_sort function, I've been trying to generate a list of random numbers to sort, and then sort them. The list is rather long, 4000, and I'd like it to be ints, but I can' seem to get it! The program compiles and runs without error, but it gives me #s far larger than integers when I print out some results. I'm using DJGPP v2. Here's some of the code... #include #include #include #define NUM 2000 int main() { int ctr; int *origp; int *onesp, *zerop; int ticks; /* for use with the clock in randomizing shtuff */ if ( !(origp = (int *)malloc(NUM * 2)) || !(onesp = (int *)malloc(NUM * 2)) || !(zerop = (int *)malloc(NUM * 2)) ) { printf("Not enough memory to run this program!!!"); } clock(); /* Initialize the clock */ (int *)ticks = clock(); srand(ticks); for (ctr = 0; ctr < NUM; ctr++) { origp[ctr] = rand(); } radix_bit_sort(origp, onesp, zerop, NUM); for (ctr = 0; ctr < 20; ctr++) printf("%d\n", origp[ctr]); free(origp); free(onesp); free(zerop); return 0; } I really need some serious help. Thanks. nicholas