Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- int i,counter = 0;
- char cpf[15];
- printf("Entre com seu cpf: (com barras e traco) :\n");
- gets(cpf);
- for (i = 0; i < strlen(cpf); i++)
- {
- if (i == 3 || i == 7)
- {
- if (cpf[i] == '.')
- counter++;
- }
- else if (i == 11)
- {
- if (cpf[i] == '-')
- counter++;
- }
- else
- {
- if (cpf[i] >= 48 && cpf[i] <= 57)
- counter++;
- }
- }
- if (counter == 14)
- printf("CPF valido!\n");
- else
- printf("CPF invalido!\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment