Char count in C

2

I have a function in C that should receive a string, and pointers that have the number of numbers and vowels that are present in the string, but the function is not adding up each time it finds a number or a vowel. Here is my code:

int main(){
    char string[12]={"5bana22anab5"};
    bool palindromo = true;
    int qtdnumero=0,qtdvogal=0,qtdoutros=0;
    informacoes(string,&palindromo,&qtdnumero,&qtdvogal,&qtdoutros);
    if(palindromo == true){
        printf("true ");
    }else printf("false ");
    printf("numeros: %d vogais: %d outros: %d",qtdnumero,qtdvogal,qtdoutros);

}

void informacoes(char str[12], bool *palindromo, int *qtdnumero, int *qtdvogal, int *qtdoutros){
    int i, j=11,igual=1;
    for(i=0;i<6;i++){
       if(str[i]!=str[j]){
          igual=0;
       }
       if(str[i]=='0' || str[i]=='1' || str[i]=='2' || str[i]=='3' || str[i]=='4' || str[i]=='5' || str[i]=='6' || str[i]=='7' || str[i]=='8' || str[i]=='9')
          *qtdnumero++;
       else if(str[i]=='a' || str[i]=='e' || str[i]=='i' || str[i]=='o' || str[i]=='u'){
          *qtdvogal++; 
       }
       else
          *qtdoutros++;

       if(str[j]=='0' || str[j]=='1' || str[j]=='2' || str[j]=='3' || str[j]=='4' || str[j]=='5' || str[j]=='6' || str[j]=='7' || str[j]=='8' || str[j]=='9')
          *qtdnumero++;
       else if(str[j]=='a' || str[j]=='e' || str[j]=='i' || str[j]=='o' || str[j]=='u'){
          *qtdvogal++; 
       }
       else
          *qtdoutros++;
       j--;
    }
    if (igual==0){
        *palindromo=false;
    }
}

The result of the function is = true numbers: 0 vowels: 0 others: 0 Does anyone have any idea why the function is not incrementing the counters?

    
asked by anonymous 21.05.2015 / 20:38

1 answer

3

The statement *ponteiro++ ( *(ponteiro++) ) increases the pointer and returns the value before the increment.
To increase the value pointed to uses (*ponteiro)++ (the value returned 'and also the value pointed before the increment).

int a[2] = {42, -1};
int *ponteiro = a;
(*ponteiro)++; // a[0] += 1;
*ponteiro++;   // ponteiro aponta para a[1]; o valor da expressao e 43
43;            // expressao com valor 43, sem efeitos colaterais
11*4-1;        // outra expressao de valor 43
(*ponteiro)++; // a[1] += 1;
printf("%d %d\n", a[0], a[1]);
    
21.05.2015 / 20:58