(userid) ~/hw2 % make hw2-utilA. There is no program hw2-util to make! hence no main() there (explaining the error message you get if you try to make it). Type 'make -k' instead.
Q. I have this line of code in my function:
arr = (long *) malloc(sizePtr * sizeof(long));With the following declaration:
long *arr;Now everytime I compile it doesn't like the multiplication I'm doing inside malloc and it gives me the following error:
Invalid operands to binary *
A.You can't multiply a pointer and an integer.
Maybe you mean *sizePtr. Maybe you don't need that pointer.
Also note, YOU SHOULD BE USING int, NOT long!
Q.
I have a question about creating the histogram.
Your instructions say :
"Your histogram should have a row for scores below lo, then as many as
are needed to have subdivisions of size step, and finally one for values
which are greater than the values in the last subdivision. The value hi
should be contained in the last subdivision, but might not actually be
the highest value in it. (In the example in the book, the first and last
row are missing.)"
I am concerned about which subdivision "hi" falls into. Should it fall into the final subdivision(values greater than the range) or into the one before that one. If, for example,
lo=10 hi=50 step=4,I would assume the subdivisions would look like this:
less than 10 10-19 20-29 30-39 40-49 50 or greaterIs this correct, or am I misinterpreting the instructions?
A. Your interpretation is incorrect on 2 counts. You should have something like the following:
below 10 10-13 14-17 18-21 etc. 48-52 /* note 50 is in here */ 53 or greater