SHARE
TWEET

Untitled

a guest Oct 14th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5.  
  6. int main(int argc, char *argv[]) {
  7.         char text[] = "aoai 1skkfd 34kdwn 99";
  8.         size_t len = strlen(text);
  9.  
  10.         char digits[10];
  11.         memset(digits, 0, 10);
  12.  
  13.         for (size_t i = 0; i < len; ++i) {
  14.                 char c = text[i];
  15.                 if (isdigit(c)) {
  16.                         digits[c - '0'] = 1;
  17.                 }
  18.         }
  19.  
  20.         printf("Digits: ");
  21.         for (int i = 0; i < 10; ++i) {
  22.                 if (digits[i]) {
  23.                         printf("%d", i);
  24.                 }
  25.         }
  26.         printf("\n");
  27.  
  28.         return EXIT_SUCCESS;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top