The problem seems that you have not allocated memory to PZDemo. Check below code for your starting point
int thresholdcount,PZLoctn_counter;
float *PZdemo = new float[sample_length];
for(thresholdcount=0;thresholdcount<sample_length;thresholdcount++)
{
if(thxcross_pos[thresholdcount]==1)
{
PZLoctn[thresholdcount]=thresholdcount;
printf("pzloctn:%f\n",PZLoctn[thresholdcount]);
PZdemo=PZLoctn[thresholdcount];
PZLoctn_counter=PZLoctn_counter+1;
}
}
for(thresholdcount=0;thresholdcount<PZLoctn_counter;thresholdcount++)
{
printf("%f\n",PZdemo[thresholdcount]);
}