Hello, I am a new learner of C.
I ran into a problem while using while loop.
The declared and initiated local int variable works well with its specified value while running through the 1st run of a while loop.
It is set zero while entering the 2nd run and the following unexpectedly.
However, the variable still exits.
I can't understand its mechanism please help me.
Thanks a lot
The following is the code with problem.
Code:#include <stdio.h> int main(void){ const int x=6; char c='y'; while(c=='y'){ //const int x=6; printf("x = %d\n",x); printf("Enter:"); scanf("%s",&c); printf("\n"); } system("pause"); return 0; }