hoss

asset_thing.c

Jun 9th, 2020
1,545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.24 KB | None | 0 0
  1. // Just a little thing to increment asset tag numbers
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5.  
  6. void inc_tag(char *format, char *tag)
  7. {
  8.     for (int i = strlen(format) - 1; i > -1; i--)
  9.     {
  10.         switch (format[i])
  11.         {
  12.         case 'A': // Alpha
  13.             if (tag[i] == 'Z')
  14.             {
  15.                 tag[i] = 'A';
  16.                 continue;
  17.             }
  18.             tag[i]++;
  19.             break;
  20.         case 'V': // Alpha, no vowels or Y
  21.             if (tag[i] == 'Z')
  22.             {
  23.                 tag[i] = 'B';
  24.                 continue;
  25.             }
  26.             tag[i]++;
  27.             switch (tag[i])
  28.             {
  29.             case 'E':
  30.             case 'I':
  31.             case 'O':
  32.             case 'U':
  33.             case 'Y':
  34.                 tag[i]++;
  35.             }
  36.             break;
  37.         case 'N': // Numeric
  38.             if (tag[i] == '9')
  39.             {
  40.                 tag[i] = '0';
  41.                 continue;
  42.             }
  43.             tag[i]++;
  44.         }
  45.         break;
  46.     }
  47. }
  48.  
  49. int main()
  50. {
  51.     char *hehe = malloc(5);
  52.     strcpy(hehe, "AA00");
  53.     for (int i = 0; i < 500; i++)
  54.     {
  55.         inc_tag("AANN", hehe);
  56.         printf("%s\n", hehe);
  57.     }
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment