fork(2) download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5. void apenasNumeros(char *texto, char *dest)
  6. {
  7. int i, j;
  8. int length = strlen(texto);
  9.  
  10. j = 0;
  11. for ( i = 0; i < length; i++ ) {
  12. if ( isdigit(texto[i]) ) {
  13. dest[j++] = texto[i];
  14. }
  15. }
  16.  
  17. dest[j] = '\0';
  18. }
  19.  
  20. int main()
  21. {
  22. char cpf[15] = "123.456.789-00";
  23. char cpfApenasNumeros[15];
  24.  
  25. apenasNumeros(cpf, cpfApenasNumeros);
  26.  
  27. printf("%s\n", cpfApenasNumeros);
  28. //getchar();
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 10304KB
stdin
Standard input is empty
stdout
12345678900