title: How to extract characters from a string in C?
body: <p>I am interfacing with GSM SIM900 module which respond with <code>\r\n</code>. I have stored the GSM response in an array and need to extract characters from it. I m checking the response in docklight and it is like this:</p>
  
  <pre><code>\r\n +CMTI: "SM",1 \r\n
  </code></pre>
  
  <p>I need to extract last integer 1 from above and store it in a variable.
  Here <code>\r\n</code> is carriage return and line feed
  I am confused that whether <code>\r</code> (carriage return) should be considered as single or double char.</p>
  
  <p><strong>Code:</strong> </p>
  
  <pre><code>char var[15] = "\r\nhello:4";
  int i,l;
  char k;
  for(i=0;i&lt;=10;i++)
  {
    if(isdigit(var[i]))
    {
      k = var[i];
      /* l = atoi(k);  */ 
      l = atoi(&amp;var[i]); /* Get number from string */
      printf("output=%d",k);        
      printf("done");
    }
    else
    {
      printf("NO");
    }
  }
  </code></pre>