Reading and reversing string using getchar in C
<p>New C coder here. I'm not certain why, but my program gets stuck in the first while loop and will not move on to the other code. Does anyone have any idea what's wrong?</p>

<pre><code>#include &lt;stdio.h&gt;

int main(void){
    char str[20];
    char reverse[20];
    int c;
    int i;
    int j;
    int k;

    printf("Enter a string: ");
    i=0;
    j=0;

    while((i&lt;20)&amp;&amp;((c=getchar())!='\n')){
        str[i] = c;
        i++;
    }

    k=i;

    while((j&lt;k)&amp;&amp;(i&gt;=0)){
        reverse[j]=str[i];
        j++;
        i--;
    }

    printf("\n");
    if(i==0){
        while(i&lt;k){
            putchar(reverse[i]);
        }
    }else{
        printf("logic error");
    }

    return 0;
}
</code></pre>

<p>Thank you!</p>