Advertisement
LightningStalker

skipstrip.c

Jun 26th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. /*
  2.  * Copies every 4th chararacter out of the input string
  3.  * Created to deal with MS Hotmail's problems
  4.  * 2015 The Lightning Stalker
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <string.h>
  9.  
  10. int main (int argc, char **argv)
  11. {
  12.     char *stringin, *stringout;
  13.     int i, j;
  14.  
  15.     if (argc == 2)
  16.     {
  17.         stringin = argv[1];   // stringin and stringout must be inited
  18.         stringout = stringin; // to strlen(argv[1]) or else segfault!
  19.         j = strlen(stringin) / 4;
  20.         for (i = 0; i <= j; ++i)
  21.         {
  22.             stringout[i] = stringin[i * 4];
  23.         }
  24.  
  25.         stringout[i] = '\0';
  26.         printf("%s\n", stringout);
  27.     }
  28.  
  29.     else
  30.     {
  31.         puts("Use like this:");
  32.         printf("%s [string]\n", argv[0]);
  33.         puts("Where [string] is the text to strip every even character.");
  34.     }
  35.  
  36.     return (0);
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement