In this function i am having problems with pointers, syntax wise this would not work ex (fstats +1)++; In this function i use fstats floater array to hold float values, now as in the functions i use
fstats[index value]++, now i'm just using pointers how would i do this??
i thought *(fstats +1)++ would increment the second position of fstats array because fstats points to the first postion but syntax wise this does not work. I am currently placing the certain index value accrodingly, kinda like cheating. How can i do this with just pointers like
fstats +1...fstats+5 and so on, want to increment the value by one in each index accordingly
void classify(char *cInput ,float *fstats)
{
int j;
int iResult =0;
float * pstatbeg;
char * pInputbeg;
pInputbeg = cInput;
pstatbeg = fstats;
for (j=0; j<=6; j++)
fstats[j]=0;
for ( ; *cInput !='\0'; cInput = cInput + 1)
{
if (isalpha(*cInput) != 0)
{
if (isupper(*cInput) !=0)
fstats [3]++;
else
fstats[4]++;
}
if(isdigit(*cInput) !=0)
{
if( (*cInput%2) == 0)
{
fstats[2]++;
iResult = *cInput - '0';
*(fstats +6) = (*(fstats + 6) + iResult);
}
else
{
fstats[1]++;
iResult = *cInput - '0';
*(fstats + 5) = (*(fstats + 5) + iResult);
}
}
fstats[0]++;
fstats = pstatbeg; //point back to beginning
}
if (*(fstats +2) ==0)
*(fstats +6) = 0;
else
*(fstats + 6) = *(fstats+6)/(*(fstats +2));
if (*(fstats + 1) ==0)
*(fstats + 5) =0;
else
*(fstats + 5) = *(fstats + 5) /(*(fstats +1));
}