# include
Void the alter (char [] a)
{
int i;
For (I=3; I>=0; I -)
{
A (2 * I + 1)=a, [I].
A (2 * I]=' ';
}
Puts (a);
}
Int main ()
{
Char a, [40].
Printf (" input a four-digit: \ n ");
The scanf (" % s ", & amp; A);
The alter (a);
return 0;
}
Why do many output something behind?
CodePudding user response:
You don't handle end, just one more,For (I=4; I>=0; I -)
CodePudding user response:
A less '\ 0'CodePudding user response:
No terminator has been print down until the end, the following is a way to modify the code, reference,
# include
Void the alter (char [] a)
{
int i;
For (I=3; I>=0; I -)
{
A (2 * I + 1)=a, [I].
A (2 * I]=' ';
}
A (2 * 4]='\ 0';//in the final end of add a
Puts (a);
}
Int main ()
{
Char a, [40].
Printf (" input a four-digit: \ n ");
The scanf (" % s ", & amp; A);
The alter (a);
return 0;
}
CodePudding user response: