#include, #ifdef, and
#ifndef.
lab1.c, with a main function in
it. Make sure it compiles.
main(), declare an array of 1000
doubles.
double
*. This function should live in a separate file, with it's
own header file. You should use the C function
drand48() to generate random numbers.
NDEBUG is not defined. If NDEBUG is
defined, the check code should not be compiled. Again, this
function should live in it's own file, and should not assume the
size of the array.
printf. Once again,
the function should not assume the size of the array is 1000.
double a[10];
int i;
for(i = 0; i < 10; ++i)
scanf("%lf", &(a[i]));
Since it's not practical to test this with a 1000-element array,
you should test that it does the right thing with a smaller array.
You can also use this to test your array sorting routine.
main() function.
lab0 --random
it will generate 1000 random numbers, rather than reading them
from the keyboard, and then sort them. Running your code without
the --random flag will read the numbers from the
keyboard.
-Wall flag.
main() and passed to the functions you
write.
infile. Running the following:
lab1 < infile > outfile
will take the contents of this file, and send them to the program,
and then take the output of the program, and send it to the file
outfile.
strcmp() function, not a
direct comparison with ==.
-Wall). Don't submit code that still causes
warnings.
chmod u+x lab1
and try again.
| Page written by Bill Smart. |