Char x [80]="AB", [80] y="LMNP";
Int n=0;
Strcat (x, y);
While (x [n++]!='\ 0')
[n] y=x [n].
Puts (y); }
A, LBB, ABLMNPC, ABD, LBLMNP
To ask, the answer is LBLMNP, but I can't understand the first L come from,
CodePudding user response:
While (n++) this sentence, judge 0, then become 1 + +, after entering the first sentence is [1] y=x [n], so y [0] remain the sameCodePudding user response:
The problem herewhile (x [n++]!='\ 0')
Cycle for the first time, n=0, since is a suffix, so the judgment on whether the x [0] is equal to '\ 0', the n value into 1, then execute the while loop body at this time, n=1
[n] y=x [n].
that is [1] y=x [1], [0] y previous value has not been x [0] cover ,
Change the code to the
while (x [n].='\ 0')
{
[n] y=x [n].
n++;
}
Can realize to complete modification of y,
CodePudding user response: