I have a declared string as follows:
char cpf[12];
I want to validate that the user entered only numbers when he entered ENTER.
I captured the value entered by the user like this:
gets(cpf);
Then I call a function that traverses this array "cpf", character by character, doing cast to convert string to int, to identify the presence of a non int.
The call looks like this:
if ((valida_cnh_cpf(cpf)) = 1) {
printf("Erro, informe somente números para CPF\n");
system("pause");
system("cls");
menu();
}
And the function was declared like this:
int valida_cnh_cpf(cpf_cnh) {
fflush(stdin);
int cpf_cnh_convertido[11];
int i;
for (i = 0; i <= strlen(cpf_cnh); i++) {
cpf_cnh_convertido[i] = (int) cpf_cnh[i];
if (isdigit(cpf_cnh_convertido[i])) {
return 0;
} else {
i = strlen(cpf_cnh) + 1;
return 1;
}
}
}
The problem is soon in the build. I get the following error pointing to the for line:
[Warning] passing argument 1 of 'strlen' makes pointer from integer without a cast
As far as I understand, it's missing casting somewhere. Could you help me identify?