Home > Article > Backend Development > printf controls newline
A program needs to use the printf function to format and wrap lines after printing.
I finished it like this
php > printf("%s",7);
7
php > printf("n");
The following method can be run, but it does not break the line
php > printf("%s",7)."n";
7
I don’t want to write
echo sprintf("%s",7)."n";
Excuse me, is there any clever way?
A program needs to use the printf function to format and wrap lines after printing.
I finished it like this
php > printf("%s",7);
7
php > printf("n");
The following method can be run, but it does not break the line
php > printf("%s",7)."n";
7
I don’t want to write
echo sprintf("%s",7)."n";
Excuse me, is there any clever way?
Please look at your code carefully printf("%s", 7) . "n"
, your "n"
is outside printf
and will not be printed at all, so there is no need to wrap it in a new line.
printf("%sn",7)