Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ alphabet equivalent digit code output program
    primarykey
    data
    text
    <p><code>I have actually this code for an embedded application. I am 1st trying to make it for plain c++ so that I may have concept clear</code>.</p> <p>I have a digit code assigned to each English alphabet. I want that my program outputs equivalent digit code for a sentence. A loop actually should iterate number of times for each digit of the code for sentence. Bec I need to ON/OFF pins for me embedded application for each digit. I have to add time difference between digits of same letter, between two letters, &amp; between two sentences later. 1st I wanted plain output for each digit of resultant code.</p> <p>Here is my code. I have assigned alphabets to String &amp; code to a String array type. Then I search for equivalent digit code of character from String array &amp; save it in string type. Now I am wanting to assign each digit from string to int &amp; loop for it. But I am having trouble in assigning string value to int. I have not much experience of C++ programming.</p> <p><strong>EDIT</strong> I have trouble in converting string to int at 1st place, &amp; overall does this logic for solving my problem seems fine. </p> <p>Here is my code, this is how I am trying to solve my problem. </p> <pre><code> #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; string texttopattern(char c) { //Hello world again //125-15-123-123-135 1346-135-1235-123-145 1-1245-1-24-1345 string alphabet = "abcdefghijklmnopqrstuvwqyz"; //osv string code[] = {"1","12","14","145", "15", "124", "1245", "125", "24", "245", "13", "123", "134", "1345", "135", "1234", "12345", "1235", "234", "2345", "136", "1236", "1346", "13456", "1356", "12346"}; int index = alphabet.find(c); if(index!=-1) return code[index]; else return " "; } int main() { string ord; getline(cin, ord); string code=""; for(int i=0; i&lt;ord.length(); i++) { code += texttopattern(ord[i]); } for(int i=0; i&lt;code.length(); i++) { int n = code[i]; //assign a single digit value from string to an //int,string2int assign value is problem here !! while(n&gt;0){ //loop for n times &amp; manipulate PIN in each iteration cout&lt;&lt;"loop"; n--; } //cout&lt;&lt;code[i]&lt;&lt;endl; } return 0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload