hi im creating a program in visual studios.net 2003 to input 40 temperature readings and stop when the number "-999" is entered. however I keep getting this error when i enter -999: Run-Time Check Failure #2 - Stack around the variable 'temp_readings' was corrupted.
could any1 please tell me whats wrong?
heres my code so far:
#include <stdio.h>
int main(void)
{
//initialise variables
int temp_readings[41];
int count = 0;
int t = 0;
int i, g;
int h=1;
//set all variables in array to 0
for(g=0; g<=41; g++)
{
temp_readings[g] = 0;
}
//while the number entered is not -999 take it and put it into the array
while(t != -999)
{
scanf("%d", &t);
if(t != -999)
{
temp_readings[count]= t;
count++;
}
}
//print all numbers that are above 30
for(i=0; i<41; i++)
{
if (temp_readings[i] >=30)
h++;
}
}