Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Just a little thing to increment asset tag numbers
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- void inc_tag(char *format, char *tag)
- {
- for (int i = strlen(format) - 1; i > -1; i--)
- {
- switch (format[i])
- {
- case 'A': // Alpha
- if (tag[i] == 'Z')
- {
- tag[i] = 'A';
- continue;
- }
- tag[i]++;
- break;
- case 'V': // Alpha, no vowels or Y
- if (tag[i] == 'Z')
- {
- tag[i] = 'B';
- continue;
- }
- tag[i]++;
- switch (tag[i])
- {
- case 'E':
- case 'I':
- case 'O':
- case 'U':
- case 'Y':
- tag[i]++;
- }
- break;
- case 'N': // Numeric
- if (tag[i] == '9')
- {
- tag[i] = '0';
- continue;
- }
- tag[i]++;
- }
- break;
- }
- }
- int main()
- {
- char *hehe = malloc(5);
- strcpy(hehe, "AA00");
- for (int i = 0; i < 500; i++)
- {
- inc_tag("AANN", hehe);
- printf("%s\n", hehe);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment