![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Convert English phrases to morse code and it‘s reverse processUse C.
Morse code are as follows:A · ━ Q ━ ━ · ━ 1 · ━ ━ ━ ━ B ━ ··· R · ━ · 2 ·· ━ ━ ━ C ━ · ━ · S ··· 3 ··· ━ ━ D ━ ·· T ━ 4 ···· E · U ··━ 5 ····· F ·· ━ · V ···━ 6 ━ ···· G ━ ━ · W · ━ ━ 7 ━ ━ ··· H ···· X ━··━ 8 ━ ━ ━·· I ·· Y ━ · ━ ━ 9 ━ ━ ━ ━ · J ·━ ━ ━ Z ━ ━ ·· 0 ━ ━ ━ ━ ━ K ━·━ L ·━ ··N ━ · () ━ · ━ ━ · ━ O ━ ━ ━ ━ ━ ··· ━ P ·━ ━· · ·━·━·━ |
|
#2
|
|||
|
|||
Re: Convert English phrases to morse code and it‘s reverse processHuh? So what's the problem?
|
|
#3
|
|||
|
|||
Re: Convert English phrases to morse code and it‘s reverse processThe problem is I don't know how to programme it.......
|
|
#4
|
|||
|
|||
Re: Convert English phrases to morse code and it‘s reverse processAre you interested in learning how?
Have you ...written, compiled and run ...a C program before? Perhaps you could describe your experience thus far. |
|
#5
|
|||
|
|||
Re: Convert English phrases to morse code and it‘s reverse processHave you even thought of what is required for such a program? Not getting into the C part, assuming this is an interactive program, you probably need something that
1. Lets user decide which mode the program operates in (character to morse / morse to character) 2. Represents morse shorts, longs and pauses. (I know nothing about morse coding, but I assume there is a pause between codes) 3. Takes input from user. 4. Converts each character or morse code to its respective morse code or character. Character-to-morse should be quite easy. For morse-to-character you could let user enter one code at a time to make it simple. 5. Displays the result. As Howard suggested, you could also tell if this is some kind of an assignment in a class or if this is just for your own fun. If this is your first C program, then it might indeed be a bit tough. |
|
#6
|
|||
|
|||
Re: Convert English phrases to morse code and it‘s reverse processReally tough work!
I've programmed a Character-to-morse function.But it doesn't work.I've tried from time to time. |
|
#7
|
|||
|
|||
Re: Convert English phrases to morse code and it‘s reverse processCPP / C++ / C Code:
Last edited by LuciWiz : 12-Jul-2007 at 00:25.
Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
|
|
#8
|
|||
|
|||
Re: Convert English phrases to morse code and it‘s reverse processPlease DO use the C++ tags found at the top of the message window to enclose your code!
Well you got some ideas of what you'd like to try. I assume it wouldn't compile... Actually I KNOW it wouldn't but it would be nice for you to include some comments regarding what YOU think problems might be. I will say that your arrays seem like a good idea. The first array will work ok and will have a terminating '\0' (null). (right dave?) But the second will need some changes before it will work. Suppose we start there. I think you might want a 2 dimensional string array. What do you think? Oh, and I'm pretty sure you should be able to google for morse code. Howard; |
|
#9
|
||||
|
||||
Re: Convert English phrases to morse code and it‘s reverse processYou've actually got a very good start.
One thing to consider is that every ASCII character has a value. 'A'=61, 'B'=62, SPACE=32, and so on. Therefore, you can make 1 single array for the Morse Code, and include punctuation, numbers, upper and lower case values. Any ASCII values that don't have an equivalent Morse Code value (like anything lower than SPACE) just make the array entry an empty string (""). Now, you can use the current character (str1[k] in your code) as an index into the Morse Code array (morse[str1[k]]) and output the string. Also, read this, this, and this __________________
Age is unimportant -- except in cheese |
|
#10
|
|||
|
|||
Re: Convert English phrases to morse code and it‘s reverse processI have a quick suggestion to make, just looking at your code it seems simple enough, now considering what walt said and what howard said maybe try something like this.
CPP / C++ / C Code:
I didn't try to compile I'm sure i made some sort of mistake somewhere but the logic of this should work for letters from A-Z with a few if statements or a switch I'm sure this should work quite well for the rest of the letters too. I am not 100% sure about my initialization of the multidimensional array any senior want to get back to me on that one? Enjoy Max |
Recent GIDBlog
Flickr uploads of IA pictures by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The