I have the following piece of code
Why do we use ch here?Code:for(i=0;(ch=getchar())!='\n';i++) s[i]=ch;
Why can't we use array directly?
Is it some kind of programming practice?
I have the following piece of code
Why do we use ch here?Code:for(i=0;(ch=getchar())!='\n';i++) s[i]=ch;
Why can't we use array directly?
Is it some kind of programming practice?
Last edited by syamprasadkr; 03-04-2013 at 07:33 PM.
If you used the array directly, the final newline would be put into the array. This code looks like it is intended to avoid that.
Code:while(!asleep) { sheep++; }
Yeah..it looks so,Thank U.