Thanks for your help. But I remember doing something similar that caused the loop to go bad when I tried to use x(woudn't identify or needed a pointer), how would I fix that?
Right now it seems like when I pass an array it either works or dosen't want to work (an thinking like that is never good in the tech. world). Also I know it's not 'junk' but it's what we called it in class when our programs accessed memory/files we didn't need.
Try adding more print statements to check the values of variables during the run. e.g. each loop print x and book[ x ] with this:
cout << " x = " << x << endl;
cout << "book[" << x << "] = " << book[ x ] << endl;
You should do this often if you're having problems with basic stuff. You should be adding print statements all over the place to check values before thinking of getting help. All professional programmers use print statements to see what variables are doing. Everyone does, because it's so effective at alerting you to errors.
Make sure that variables have the values that you expect. You can also add a print statement to detect errors which should not occur, e.g. each time you access an array you can check the value that's being used as the index:
if(x < 0 || x >= size)
{
cout << "I dun passed the wrong value" << endl;
}
for example, a 10-element array goes from 0 to 9, so it would be an error to pass it an x value of <= -1 or >= 10.