OK, before we begin, let's remind ourselves that I'm a hardware designer by trade. When it comes to software in general -- and C in particular -- I know only enough to be dangerous.
I have a project on the go at the moment. This is a secret squirrel project whose purpose -- for the present -- must remain a riddle, wrapped in a mystery, inside an enigma. Suffice it to say that I wish to use a light-emitting diode LED to flash messages in Morse code.
My question pertains to the best way in which to represent, store, and access the Morse code dots and dashes used to represent the numbers and letters.
Ultimately, I want to be able to initialize a string with a message I wish to transmit using a statement like:
char my_string = "HELLO WORLD";
Later, I'll pass this string as a parameter into the function that will actually flash the LED. So, once again, my question is: "What's the best way to represent the dots and dashes associated with the various characters?" My very first pass thought was to store these as character strings themselves -- something like the following:
char string_A = ".-";
char string_B = "-...";
char string_C = "-.-.";
:
I know that this technique of using a separate character for each dot and dash doesn’t give the smallest memory footprint, but it does have the advantage of understandability, which is, of course, an important consideration. On the other hand, the scheme shown above -- having individual strings for each of the character -- would be difficult to use.
The bottom line is that every approach I can think of is less than optimal or incongruous, which is why I'm inviting your ideas. If you think of anything -- preferably pertaining to this perplexing poser -- please post it as a comment below.
用户1406868 2015-10-23 14:31
用户1406868 2013-6-15 08:04
用户1406868 2013-6-15 08:03
用户1697450 2013-6-10 13:02
tomfans_771914403 2013-6-4 17:12
用户1602177 2013-6-4 13:49
用户1602177 2013-6-4 13:45
用户1602177 2013-6-4 13:43
用户1406868 2013-6-1 14:19
yfy812_845263591 2013-5-31 18:10