title: Converting character buffer to an integer (arduino)
body: <p>SOLVED:</p>
  
  <p>You can change the char buffer by using:</p>
  
  <pre><code>char *arg;
  arg = SCmd.next();
  int i;
  sscanf(arg, "%d", &amp;i);
  Serial.print("String value "); 
  Serial.println(arg); 
  
  Serial.print("Integer value "); 
  Serial.println(i); 
  </code></pre>
  
  <hr>
  
  <hr>
  
  <hr>
  
  <p>PROBLEM:</p>
  
  <p>I can't seem to figure out how to change a char buffers contents to an integer from a stored string.</p>
  
  <p>For instance:</p>
  
  <p>'1' should be 1, </p>
  
  <p>'121' should be 121</p>
  
  <p>Here's what I tried.</p>
  
  <pre><code>void doIt()
  {
    char *arg;
    arg = SCmd.next();    // Get the next argument from the SerialCommand object buffer
  
    if (arg != NULL)      // As long as it existed, do it
    {
      int argInted = (int)arg; // Cast char arg* -&gt; int argInted.
  
      Serial.print("String value "); 
      Serial.println(arg); 
  
      Serial.print("Integer value "); 
      Serial.println(argInted); // Print this new found integer.
    } 
    else {
      Serial.println("Fix your arguements"); 
    }
  }
  </code></pre>
  
  <p>Here's what I get, it evaluates to 371 every time. I'm storing different things in the pointer buffer though, any ideas on how to convert?</p>
  
  <pre><code>Arduino Ready
  &gt; INPUT 1
  String value 1
  Integer value 371
  &gt; INPUT 2
  String value 2
  Integer value 371
  &gt; INPUT WHATSthisDO
  String value WHATSthisDO
  Integer value 371
  </code></pre>