|
PC-based compiling Course Design Compiling Hints Scanf() information. Assorted C routines. Program files Useful, free, scientific software. Java Code (unmaintained). |
Compiling Hints under Unix
Many thanks to Leonardo Frid (Zoology, UBC) who prepared this table that shows the effect of various combinations of various features on compilation. He used bd.c from Chapter 2.The first column is the compilation command used to compile. The second column involves declaring drand48() above the main() routine. The declaration is not made in the code I provide. The third column is whether void is placed inside the main declaration, i.e., int main(void) {...}. The fourth column tells what happens with the compilation/executable. Syntax error means it didn't compile, constant 10 is a wrong result, correct means the executable produces the numbers shown in the book.
This is the case for Leonardo. I tried the starred ones and they worked fine on my Linux system, I then used the "-ansi" flag (enforcing strict adherence to ANSI) and got constant 10s in both cases. If your compiler has a strict adherence to the ANSI standard you may need to globally declare the random number generator. Before main(), add the line: double drand48(); I hope this information helps. |