title: Build my own scanf function
body: <p>For academic purposes, I have to build my own atoi() and scanf() function.</p>
  
  <p>The first one was pretty simple but I'm having trouble with the second one.</p>
  
  <p>first one:</p>
  
  <pre><code>int String2Inteiro (char s[])
  {
      int j;
      int i=0;
      for(j=0; s[j]!= 0; j++) 
      {
  
          i=i*10 + s[j] - '0';
      }
  
      return i;
  }
  </code></pre>
  
  <p>Now in the second one I'm having some issues that I think that are related to the stop condition.
  My first attempt was trying to stop after the cicle.</p>
  
  <pre><code>char dig;
  int cont=0;
  
  do
  {
      dig=getchar();
      array[cont]=dig;
      cont++;
  } while (dig!= '\n');
  </code></pre>
  
  <p>The second attempt was:</p>
  
  <pre><code>int counter=0;
  char a;
  char array[20];
  
  while (a!='\n')
  {
      a=getchar();
      vec[counter]=a;
      counter=counter+1;
  }
  </code></pre>
  
  <p>I'm not sure if the enter is well represented or if i should had use '\13' (ASCII code of CR).</p>
  
  <p>Thanks in advance,</p>
  
  <p>André</p>