Home > Back-end >  C language output, the output noise, more help!!!!!
C language output, the output noise, more help!!!!!

Time:01-26

 
# 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:

reference 1st floor forever74 response:
you don't have the handle end, more than one line,
For (I=4; I>=0; I -)

Thank you thank you very much

CodePudding user response:

reference room reply: 3/f the cloud
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;
}

OK I understand you thank you thank you
  • Related