X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=morse.c;h=eb0bd8ee4f3c7db0609a6bba37b19ab4657bfcbc;hb=26ce4f633da6e65105ff9d9046b760d28a4a3809;hp=27e0fa600d8913f52b91e77f487b1050819d9726;hpb=b3c96cc961404fea566c2cdde320008a33984284;p=bin.git diff --git a/morse.c b/morse.c index 27e0fa6..eb0bd8e 100644 --- a/morse.c +++ b/morse.c @@ -1,5 +1,5 @@ /* Convert ASCII to morse code. Reads from stdin if provided with no argument - or "-", otherwise reads from the first command line argument. Prints "*" if + or "-", otherwise reads from the first command line argument. Prints "?" if character is not found. */ #include @@ -7,14 +7,17 @@ #include #include -const char *aa[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", - "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", - "2", "3", "4", "5", "6", "7", "8", "9", "0", " "}; +const char *aa[] = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", + "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", + "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", + "5", "6", "7", "8", "9", "0", " "}; -const char *ma[] = {"•-", "-•••", "-•-•", "-••", "•", "••-•", "--•", "••••", - "••", "•---", "-•-", "•-••", "--", "-•", "---", "•--•", "--•-", "•-•", "•••", - "-", "•--", "•••-", "•--", "-••-", "-•--", "--••", "•----", "••---", "•••--", - "••••-", "•••••", "-••••", "--•••", "---••", "----•", "-----", " "}; +const char *ma[] = {"•-", "-•••", "-•-•", "-••", "•", "••-•", "--•", + "••••", "••", "•---", "-•-", "•-••", "--", "-•", + "---", "•--•", "--•-", "•-•", "•••", "-", "•--", + "•••-", "•--", "-••-", "-•--", "--••", "•----", + "••---", "•••--", "••••-", "•••••", "-••••", + "--•••", "---••", "----•", "-----", " "}; void convert(char *c) @@ -29,7 +32,7 @@ convert(char *c) printf("%s", ma[i]); break; } else if (i == sizeof(aa)/sizeof(char *) - 1) { - printf("*"); + printf("?"); } } printf(" "); @@ -38,6 +41,7 @@ convert(char *c) int main(int argc, char **argv) { + (void)argc; char c[2]; c[1] = '\0';