Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7.     if (argc > 0)
  8.     {
  9.         char *input = argv[1];
  10.         int len = strlen(input);
  11.         char *buf = malloc((len * sizeof(char)) + 1);
  12.         int i = 0, j = 0;
  13.         for (; i < len; i++)
  14.         {
  15.             char c = input[i];
  16.             if (c >= 48 && c <= 57)
  17.                 buf[j++] = c;
  18.         }
  19.         buf[j] = '\0';
  20.  
  21.         printf("%s\n", buf);
  22.         free(buf);
  23.     }
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement