So, I’m having a problem - I’ve figured out I can do this easily with a big case statement, but it is not efficient at all and I dislike it.
I have two arrays, both are the same size, one represents characters in one language and the second array, the same characters but in a different language.
I have tried iterating with a for loop the length of the arrays, but it did not work.
This loop is inside a function, with its parameter set as C. The function receives inputs like ‘E’, or ‘O’. There aren’t any error codes however it also produces no output for me.
a) please make a small compileable prototype which shows your problem. This part of code doesn't show your specific error. Don't forget to post code in code tags
b) just in case if your variable letters would containt 'A', 'B', 'C', I guess it is not needed at all
as you can access morse[i] with a simple
i = c - 'A';
if c would be 'B', i becomes 1 -> the second value in your array therefore no need for array letters
You can't use strcmp() on char variables. It only works with strings. In C, strings are arrays of char with a null character (code 0) indicating the end of the string.
Your earlier code was better in this respect, but it was not complete, so we could not tell you what the problem was.
You could be more helpful, when it comes to "saving the lives" of other beginners. For example, other beginners may be searching for help, find this topic and wonder why I told you not to use strcmp() and why I thanked your for using code tags? They will never see the post you deleted where you posted, using code tags, code using strcmp() so this topic will make no sense and confuse them even more. So, please never delete posts and only modify previous posts to do things like correcting spelling errors or adding code tags when they were forgotten. Don't delete or modify a topic in a way which means it no longer makes sense as a "story" for others reading it.