int main() { int i, n, len, wc; char word[MAX_WORD], line[MAX_LINE], soln[MAX_WORD], *pline; scanf("%d\n", &n); dprintf("n = %d\n", n); for (i = 0; i < n; i++) { memset(dict[i], '\0', MAX_WORD); scanf("%s\n", dict[i]); idict[i] = strlen(dict[i]); dprintf("word[%d] = %s, len %d\n", i, dict[i], idict[i]); } memset(line, '\0', MAX_LINE); while (fgets(line, MAX_LINE, stdin)) { for (i = 0; i < MAX_ALPHA; i++) { decoder[i] = INVALID_CODE; alpha_candidates[i] = 1; } for (i = 0; i < MAX_DICT; i++) { candidates[i] = 1; } dprintf("line: %s", line); pline = line; wc = 0; while (*pline != '\0') { memset(crypt[wc], '\0', MAX_WORD); sscanf(pline, "%s", crypt[wc]); icrypt[wc] = strlen(crypt[wc]); decypher(wc); pline += icrypt[wc]+1; wc++; } dprintf("wc: %d\n", wc); for (i = 0; i < wc; i++) { decode(crypt[i], icrypt[i]); } printf("\n"); memset(line, '\0', MAX_LINE); i = 0; } return 0; }
int main(){ char choose; do{ char text[1000]; printf("Enter option:"); scanf("%c",&choose); getchar(); if(choose=='c'){ printf("Enter text:"); scanf("%1000s", text); cypher(text); getchar(); } if(choose=='d'){ printf("Enter text:"); scanf("%1000s", text); decypher(text); getchar(); } }while(choose!='q'); return 0; }