I wrote this code in a pinch to take a string and “add one” to it. Essentially, this code will take a fixed-length string, and iterate through every possible combination of characters available. For example, if argv[2] is set to 8, it will start with “!!!!!!!!” and go through every combination until it reaches “zzzzzzzz”. The string will also be null-terminated, too. Thought this might be useful to some people out there, and you should know exactly the application for a function like this…

char* tosend = (char*)calloc(atoi(argv[2])+1, sizeof(char));
for(i = 0; i < atoi(argv[2]); i++) { tosend[i] = (char)33; } tosend[i] = '\0'; for(j = atoi(argv[2]); j >= 0; j–)
{
if(*(tosend+((j-1)*sizeof(char))) != ‘z’)
{
*(tosend+((j-1)*sizeof(char))) = *(tosend+((j-1)*sizeof(char))) + 1;
while(*(tosend+((j)*sizeof(char))) != ‘\0’)
{
*(tosend+((j)*sizeof(char))) = ‘!’;
j++;
}
break;
}
}