I was required to write a function to read the input and store it in a array. However, it didn't work. The size will somehow changed to a random number after 2 rounds, and the loop will stopped.
Could anyone point out where I did wrong? I have been trying to slove it for hours...
Your exam score array has one element. That means after first round all writes will be done out of bounds. It liiks like one of them corrupted your size variable.
Thank you for the help!
Yea, I wish I can use vector to solve it but that's too advanced for this class...(I have to show my understanding to the current content...)
I finally figured I should just use
double* getExamScoreFromUser(double* score, int size)
which made things easier... :P
But I also understand what you were saying, I think the requirement said we could set the array a size, which we will have to do a size check to make sure user won't input a size that is too big. I personally don't like static array, so I ignored it...my bad :P