title: Formatting input (removing leading zeros and decimal places) in C90?
body: <pre><code>#include &lt;stdio.h&gt;
  
  int intVal(int x)
  {
      if(x &lt; '0' || x &gt; '9'){
          return 0;
      }
      else{
          x = x - '0';
          return x;
      }
  }
  
  int main(void)
  {
      int c, num, prev;
  
      while((c = getchar()) != EOF){
          num = (intVal(prev) * 10) + intVal(c);
          prev = num;
          printf("%d", num);
      }
      return 0;
  }
  </code></pre>
  
  <p>What I want to do with this program is input an arbitrary number to be read a char at a time, then format it into an int so that I can work with it (Don't want to use printf formatting)  Also, I am only allowed to use getchar and printf for this assignment.  </p>
  
  <p>Sample Input: 0001234.5<br>
  <em>edit</em> Desired Output: &lt;1234>(5)
  Actual Output: 0001234050</p>
  
  <p>I feel like I'm on the cusp of an epiphany but I've hit a roadblock, please help?</p>
  
  <p>*edit I forgot to mention that the END result I am going for is to have the non-decimal numbers enclosed in &lt;1234> and the decimal numbers in brackets (5)</p>