P> Notes on learning PHP function sprintf ()SprintfFormat the string.Syntax: string sprintf (string format, mixed [args]...);Return Value: StringCorrespondence type: Data Processing DescriptionThis function is used to format the string. The format
Problem description:
The engine has been running stably for a long time. It is also stable on all computers.
However, only one notebook does not work. The engine collapsed when running on it.
Problem Analysis:Based on the generated dump file,
Recently, I found a bug in my project and killed the process. I checked it and found it was the most inconspicuous place. I will record it here.
First look at the following code
# Include # include using namespace STD; int main () {char AA [1024]
/**** Javascript sprintf* http://www.webtoolkit.info/**%%–returns A percent sign*%b–binary number*%c–the Cha Racter according to the ASCII value*%d–signed decimal number*%f–floating-point number*%o–octal number*%s–s tring*%x–hexadecimal Number
-Echo
is a command and cannot return a value. Echo can be followed by many parameters, separated by semicolons, such as:
echo $myvar 1;
Echo 1,2, $myvar, "bold";
-Print
is a function that can return a value and can have only one argument.
First, EchoEcho () is not actually a function, it is a PHP statement, so you do not need to use parentheses on it. However, if you want to pass more than one argument to Echo (), a parse error occurs when you use parentheses. and echo returns void
There should be a lot of discussions about strcpy, sprintf, and strcat insecure functions. We all know that they can be replaced by strncpy, snprintf, and strncat. However, in actual work, it seems that these "Security edition" functions still bring
The first parameter required by wsprintf is lptstr. if the environment is Unicode, lptstr is equivalent to wchar_t *, which is a wide character pointer and char * in a non-Unicode environment *.
The function for formatting strings is as follows.
PHP basics echo print printf sprintf print_r var_dump usage and difference, print_rvar_dump1. echoEcho () is actually not a function, it is a php statement, so you do not need to use parentheses for it. However, if you want to pass more than one
Test environment: Keil C51 + stc89c52DescriptionThe 1.keil has an indeterminate parameter of only 15 bytesThat is, sizeof (...) cannot add up to 15 bytes in total, or it will go wrong.2. When there are constants in the indeterminate parameter, you
Instance
Replace the percent sign (%) with a variable that is passed as a parameter:
Definition and usage
The sprintf () function writes a formatted string to a variable.
The Arg1, arg2, + + parameters are inserted into the percent sign (%) symbol
This article provides a detailed analysis of the differences between echo, print, print_r, sprintf, var_dump, and var_expor in php. For more information, see
/******* Echo ********/Echo-output one or more strings
DescriptionEcho (string arg1 [,
-Echo
is a command and cannot return a value. Echo can be followed by a number of parameters, separated by semicolons, such as:
echo $myvar 1;
Echo, $myvar, "bold";
-Print
is a function that returns a value that can have only one
[Convert] the difference between PHP: echo, print, print_r, sprintf, and var_dump-echo is a command and cannot return a value. Echo can be followed by multiple parameters separated by semicolons, such as echo $ myvar1; echo1, 2, $ myvar, & lt; B &
Code:
#include
int main ()
{
char data1[10];
Char data2[10];
int Ret1, Ret2;
Ret1 = sprintf (data1, "My name is Messi, I ' m%d Years old!",);;
printf ("%s\n", data1);
Ret2 = snprintf (data2, sizeof (DATA2), "My name is Messi, I ' m%d
Differences in use of phpecho, print, print_r, sprintf, var_dump, and var_expor. * ******* Echo-output one or more string descriptions echo (stringarg1 [, string...]) echo () is actually not a function (it is a language structure), so you
/*******
Definition and usageThe sprintf () function writes a formatted string to a variable.Grammarsprintf (format,arg1,arg2,arg++)
Parameters
Description
Format
Necessary. Conversion format.
Arg1
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.