- if (n == 0)
- sprintf(buf, "%c", (int)(set+'a'-1));
- else
- sprintf(buf, "%c+%d", (int)(set+'a'-1), n);
+ if (n != 0) {
+ sprintf(buf, "+%d", n); /* Just to get the length... */
+ p -= strlen(buf);
+ sprintf(p, "+%d", n);
+ } else {
+ *p = '\0';
+ }
+ do {
+ set--;
+ p--;
+ *p = (char)((set % 26)+'a');
+ set /= 26;
+ } while (set);