Comparison of elements of a vector with stcmp

-1

In the following function I want to compare the elements of an array of 1000, but I can not find a way to compare them successfully, even using strcmp() .

void verifica_conta(int *ptr) {
    int i; //Posição
    for(i = 0; i < 1000; i++){
       if(strcmp(*ptr, *(ptr+i)) == 0) {
          printf("\tConta já existente\n");
    }
}
    
asked by anonymous 01.11.2017 / 04:43

1 answer

2

It does not make sense to compare two integers with strcmp() as this function compares string .

It would look something like this:

void verifica_conta(int *ptr) {
    for (int i = 0; i < 1000; i++) if (ptr[0] == ptr[i]) printf("\tConta já existente\n");
}

But it's likely to have a logic error too.

    
01.11.2017 / 06:01