title: Converting string to int in Turbo C
body: <p>Good day! Can I ask how to convert a string to int in turbo C.
  For example:</p>
  
  <pre><code>void comp()
  {
      FILE *fp;
      int i,x;
      long int deci;
      char bin[8];
      char *str=0;
      char buf[1024];
  
      fp=fopen("C:\enc.txt","w");
  
      printf("Enter a text: ");
      scanf("%[^\n]",str);
      init(str);
  
      for(i=0;i&lt;128;i++)
      {
          if(code[i])
          {
              printf("'%c': %s\n",i, code[i]);
          }
      }
  </code></pre>
  
  <p>I'm making a binary code here with the use of string. </p>
  
  <pre><code>    encode(str, buf);
      deci=decimal(buf);
      printf("%li", deci);
  
      fprintf(fp,"%s",deci);
  
      fclose(fp);
  
  }
  </code></pre>
  
  <p>Here is the function decimal()</p>
  
  <pre><code>int decimal(long int decimal)
  {
      int dc, power;
      power=1;
      ht=0;
      while(decimal&gt;0)
      {
          dc+=decimal%10*power;
          decimal=decimal/10;
          power=power*2;
      }
      return dc;
  }
  </code></pre>
  
  <p>Thanks for the responses!</p>