Skip to content

Instantly share code, notes, and snippets.

@iamarkdev
Last active December 4, 2016 08:04
Show Gist options
  • Save iamarkdev/9302207e5d54bac097ebff0eb050ce06 to your computer and use it in GitHub Desktop.
Save iamarkdev/9302207e5d54bac097ebff0eb050ce06 to your computer and use it in GitHub Desktop.
Expand shorthand inputs (I.E a-z becomes a b c d ... x y z, etc)
#include <stdio.h>
int main() {
int c;
char line[] = "";
for (int i = 0; (c = getchar()) != EOF; i++) {
line[i] = c;
if (c == '\n') {
i = -1; // ++ will set this back to 0, probably a better way?
line[0] = '\0';
continue;
}
if (i < 2) {
continue;
}
if (line[i - 1] == '-') {
int end = line[i];
for (int pos = line[i - 2]; pos <= end; pos++) {
printf("%c\n", pos);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment