My buddy runs this program fine in his C++ editor but when I run it in Cygwin after I enter 3 temperatures I get this: 7 [main] a 26966 _cygtls::handle_exceptions
: Error while dumping state (probably corrupted stack) Segmentation fault (core dumped)
Everything seems to be syntactically correct from a C standpoint though. If anyone can decipher this error I appreciate....
The code:
#include <stdio.h>
#include <stdlib.h>
int ave,temp_total,sum_total=0,total;
int b,cnt=0,*pb;
int input[3];
void calc(int *pb)
{
cnt = cnt++;
pb = &input[b];
temp_total = (sum_total + *pb);
sum_total = temp_total;
}
int main(void)
{
for (b=0;b<3;b++)
{
printf("Enter a value: ");
scanf("%d", &input[b]);
calc(pb);
}
ave = (sum_total/cnt);
printf("Cold Ave is %d\n", ave);
return 0;
}