I am writing a code and i hope this summon my problem. Any help is appreciated>
I created an array by:
intermediateBinCounts = (int *)malloc(bin_count * thread_count * sizeof(int));
and want it to increment value in another function:
for(int i=privateStartingIndex; i<privateEndingIndex; i++){
int returnedBinIndex = findBin(data[i]);
int intermBinCountIndex = (threadIndex*bin_count)+returnedBinIndex;
intermediateBinCounts[intermBinCountIndex]++;
printf("\nthis is value %d\n", intermediateBinCounts[intermBinCountIndex]);
}
intermBinCountIndex is integer which is returned from the function and their value in my case are among 0, 1, 2, 3 only.
but my printf is returning:
this is value -1163005938
this is value -1163005937
this is value -1163005938
I don't know if my question is able to articulate my issue if it is not able to please let me know so that I could edit it again my best.
I want that intermediateBinCounts to be initialized to zero and increment the value at that index which value is returned from the function call i.e findBin.