title: English to Morse Converter
body: <p>I've been working on a program that is supposed to convert english to morse code. I am having a really hard time dealing with the strings. For example I have no clue why I can have morseAlphabet have a set number of positions at [30] but I cannot do the same for latinAlphabet. Overall I have no clue how I am supposed to translate the words.</p>
  
  <p>My idea was to see what character in the alphabet shows up in the first position of the phrase to be translated then print the corresponding alphabet position for the morse alphabet then move onto the second position in the phrase however me messing around with for loops just ended with me getting errors about for loops getting far too huge and memory errors or just gave me a blank.</p>
  
  <p>With what I have right now whenever I enter the phrase to be translated it comes stops with a subscript out of range error and some of my earlier fiddling had it return jibberish(memory locations?) and I am really just out of ideas. I hope that this is phrased right and someone can help me because the past four hours of internet searches hasn't really helped me and to be honest at this point I am doubting if any of the stuff I've written is any use at all.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  
  int main()
  {
      int operatingMode = 0;
      using namespace std;
      std::string latinPhrase;
      std::string morsePhrase;
      std::string latinAlphabet = { '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', '.', ',' };
      std::string morseAlphabet[30] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", ".-.-.-", "--..--" };
      std::string translatedMorsePhrase;
      int wordSearch = 0;
  
  
      std::cout &lt;&lt; "Please select a mode of operation. " &lt;&lt; endl;
      std::cout &lt;&lt; "Input 1 for English to Morse and 2 for Morse to English. " &lt;&lt; endl;
  
      std::cin &gt;&gt; operatingMode;
  
      std::cout &lt;&lt; "Your mode of operation is " &lt;&lt; operatingMode &lt;&lt; endl;
  
      if (operatingMode == 1)
      {
          std::cout &lt;&lt; "You have selected English to Morse." &lt;&lt; endl;
          std::cout &lt;&lt; "Please enter the phrase you would like translated." &lt;&lt; endl;
  
          std::cin.ignore();
          std::getline(std::cin, latinPhrase);
      }
  
      for (int counter = 0; counter &lt; 30; counter++)
      {
          for (unsigned i = 0; i&lt;latinPhrase.length(); ++i)
          {
                  if (latinPhrase.at(i) == latinAlphabet[i])
                  {
                      cout &lt;&lt; morseAlphabet[i];
                  }
          }
  
          std::cout &lt;&lt; "The translated phrase is: " &lt;&lt; translatedMorsePhrase &lt;&lt; " stop" &lt;&lt; endl;
  
  
      return 0;
  }
  </code></pre>