I'm new into C and I'm kinda lost with these overflow and underflow things. I've a few noobs questions in my mind that I've to ask to someone.
I'm doing some leetcode problems, and I'm stuck on this one because of a runtime error telling me that I've a heap-buffer-overflow.
It is supposed to calculate the average of a given int array.
double average(int* salary, int salarySize){
int i = 0;
double count = 0.0;
while (salary[i] != salarySize)
count += salary[i++];
return (count / salarySize);
}
Thanks in advance, hope i'll figure out what's not working.
I tried with a for loop, it works great but I wanted to know why it isn't working with while loops ?