#include #include #include #include typedef struct { int is_letter; int number; char letter; } Character; static void Chomp(char *p) { size_t l = strlen(p); while (l && p[l-1] == '\n') { p[--l] = 0; } } static void Error(const char *p) { perror(p); exit(EXIT_FAILURE); } int main(int argc, char *argv[]) { int no_chars; Character *chars; int f; FILE *fp; char buff[1024]; if (argc < 3) { fprintf(stderr, "usage: %s wordlist ...\n", argv[0]); exit(EXIT_FAILURE); } no_chars = argc - 2; chars = malloc(sizeof *chars * no_chars); if (!chars) { Error("malloc"); } for(f = 0; f < no_chars; f++) { int i; i = atoi(argv[f+2]); if (i == 0) { chars[f].is_letter = 1; chars[f].letter = argv[f+2][0]; chars[f].number = 0; } else { chars[f].is_letter = 0; chars[f].number = i; chars[f].letter = 0; } } fp = fopen(argv[1], "r"); if (!fp) { Error(argv[1]); } while(fgets(buff, sizeof buff, fp)) { } return EXIT_SUCCESS; }