Print numbers until a negative number is entered
<p>My problem is not related to <code>scanf();</code></p>

<p>For example: input -> <code>542-4Output</code> -> <code>5,4,2,-4</code> </p>

<p>I mean, print until negative number with negative number. It's okey until negative number, but I want to print negative number too. How can I do ? Please help me. I used <code>getchar()</code>, <code>isdigit()</code>, <code>int a=x-'0'</code></p>

<pre><code>char x =getchar();
while(isdigit(x)){
    int a=x-'0';
    printf("%d,",a);
    x=getchar();
}
</code></pre>