I have written a simple function which reads in a pointer to an array. It looks at the elements of the array and compares adjacent values for equality. If they are equal it adds their value to "sum"
I am getting a runtime error telling me "local "sum" was referenced before being initialized." I don't understand this because sum is definitely initialized in my function. See code snipet.
int arrRead (char *Pinput){
int sum, a, b = 0;
while (*Pinput){
a = *Pinput;
++Pinput;
b = *Pinput;
if(a == b)
sum += a;
}
return sum;
}