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?
Printable View
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?
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.
Yeah..it looks so,Thank U.