Hi. this is my first post so Im sorry if it's in the wrong place.
I havn't been programming in C for very long but I'm already really liking it but I am stuck on a certain problem. For a simple text based adventure game Im writing (this may be a big project for a novice like me, but I feel that it's a good way to learn lots of different aspects of C while having fun at the same time). I want to be able to translate what a user types in, into morse code. I was going to use a switch statement for each letter etc but decided that was a very long way of doing this so I did some searching on Google and read stuff on the strncpy function but im having trouble with it. Ive got a charachter array that contains all morse code symbols, to make it more uniform I added spaces where necessary to make everything 4 charachters long (ie instead of ".-" for 'a' ive got ".- ")
char MorseData = ".- -...-.-.-.. . ..-.--. ...... .----.- .-..-- -. --- .--.--.-.-. ... - ..- ...-.-- -..--.----..";
Now depending on what the user enters I want to be able to translate those letters into there equivalent morse code. I was thinking something along the lines of converting the charachters into their Ascii code equivilent (which I havnt figured out yet) and then using a loop to convert them all into morse code but Ive been trying different things for so long I just cant do it. Once Ive got this (most likely basic thing) working I will then try to make it so the user can read a file in of either morse code or standard text and translate it but I figure that will also be a very simple (yet complicated thing for me) function and I will probably need further help.
I am very grateful for any help I am given, thankyou.
If this post doesnt make much sense I will try to answer any questions to clarify myself.
Again, thanks for any help given.