redirect, resulting in an unnecessary handshake.4. The Facebook server responds with a permanent redirect (permanent redirect response for Facebook Service)The figure shows the response that the Facebook server sends back to the Browser:http/1.1 301 Moved Permanentlycache-control:private, no-store, no-cache, must-revalidate, post-check=0,Pre-check=0expires:sat, 00:00:00 GMTlocation:http://www.facebook.com/p3p:cp= "DSP law"Pragma:no-cacheset-cookie:made_write_conn=deleted; expires=thu, 12-feb-20
05:09:50 GMT;path=/; domain=.facebook.com; HttpOnlycontent-type:text/html; Charset=utf-8X-cnection:closeDate:fri, 05:09:51 GMTcontent-length:0The server responds with a 301 permanent redirect response to the browser so that the browser accesses "http://www.facebook.com/" rather than "http://facebook.com/".Why does the server have to redirect rather than directly send the Web content that the user wants to see? There are many interesting answers to th
variable of the corresponding position, producing a string that the caller wants.Formatting numeric stringsOne of the most common applications of sprintf is to print integers into strings, so sprintf can be substituted for most occasionsItoaSuch as:The integer 123 is printed into a string stored in S.sprintf (S, "%d", 123); Generate "123"You can specify a width, insufficient left fill space:sprintf (S, "??", 123, 4567); Generated: "123 4567"Of course, you can also align Left:sprintf (S, "%-8d",
, because the browser is not clear whether Folderorfile is a folder or file, so cannot automatically add slashes. At this point, the browser does not have a slash directly access to the address, the server responds to a redirect, resulting in an unnecessary handshake.4. Permanent redirect response for Facebook servicesThe figure shows the response that the Facebook server sends back to the browser:http/1.1 301 Moved PermanentlyCache-control:private, No-store, No-cache, Must-revalidate, Post-chec
); // generate: "123 4567"You can also print the data in hexadecimal format:
Sprintf (S, "% 8x", 4567); // lowercase hexadecimal notation, with 8 width positions and right alignment
Sprintf (S, "%-8x", 4568); // in hexadecimal notation, the width occupies 8 positions and is left aligned.In this way, the hexadecimal string of an integer is easy to obtain, but when printing the hexadecimal content, we usua
of the most common applications is to print Integers to strings. Therefore, spritnf can be replaced in most cases.ITOA.
For example:// Print the integer 123 into a string and save it in S.Sprintf (S, "% d", 123); // generate "123"You can specify the width. If the width is insufficient, spaces are filled on the left:Sprintf (S, "% 8d % 8d", 123,456 7); // generate: "123 4567"Of course, you can also align left:Sprintf (S, "%-8d % 8d", 123,456 7); // generate: "123 4567"You can also print the da
of the most common applications is to print Integers to strings. Therefore, spritnf can be replaced in most cases.ITOA.
For example:// Print the integer 123 into a string and save it in S.Sprintf (S, "% d", 123); // generate "123"You can specify the width. If the width is insufficient, spaces are filled on the left:Sprintf (S, "% 8d % 8d", 123,456 7); // generate: "123 4567"Of course, you can also align left:Sprintf (S, "%-8d % 8d", 123,456 7); // generate: "123 4567"You can also print the da
applications of sprintf is to print Integers to strings. Therefore, spritnf can replace ITOA in most cases.
For example:// Print the integer 123 into a string and save it in S.Sprintf (S, "% d", 123); // generate "123", you can specify the width, left fill space:Sprintf (S, "% 8d % 8d", 123,456 7); // generate: "123 4567", of course, it can be left aligned:Sprintf (S, "%-8d % 8d", 123,456 7); // generate: "123 4567"
You can also print the data in hexadecimal format:Sprintf (S, "%
("% *. * Shh \ n", n, m, CH); // output "12345678hh" here"
Int y= 456;// Here # 8D, keep the width. If it is not 8 characters long enough, fill it with spaces on the left.// If the number exceeds 8 bits, the number of BITs is output.Printf ("% # 8d \ n % # 8x \ n % # 8o \ n", Y, Y, y );Printf ("% # 3D \ n % # 3x \ n % # 3O \ n", Y, Y, y );Printf ("% # 1D \ n % # 1x \ n % # 1O \ n", Y, Y, y );
// The. 8d here is estimated to be familiar to everyon
most common applications of sprintf is to print Integers to strings. Therefore, spritnf can replace ITOA in most cases.
For example: // print the integer 123 into a string and save it in S. Sprintf (S, "% d", 123); // generate "123"
You can specify the width, with spaces filled on the left: sprintf (S, "% 8d % 8d", 123,456 7); // generate: "123 4567"
Of course, it can also be left aligned: sprintf (S, "%-8d % 8d", 123,456 7); // generated: "123 4567"
It can also be printed in hexadecimal
printf will%f the output by double type, that is, the parameter float type will be converted to double type in the output.But now is not%f, of course, using%f to show the correct results. So I guess, printf is the float type read into the data are automatically converted to double type, and then%f double processing, and we this is%d, so the display of float converted to a double type of low 4 bytes.Verify this idea: #include "stdio.h"int main (int argc, char* argv[]){Double F = 5.01;int *p = (i
Common methods for NSString strings2010-09-06 14:18/*******************************************************************************************NSString*******************************************************************************************/First, NSString/*----------------method to create a string----------------*/1. Create a constant string.NSString *astring = @ "This is a string!";2, create an empty string, give the assignment.NSString *astring = [[NSString alloc] init];Astring = @ "This is
4567" can also be printed according to the 16 binary:sprintf (S, "%8x", 4567); lowercase 16 Binary, Width 8 positions, right justifiedsprintf (S, "%-8x", 4568); Uppercase 16 binary, Width 8 positions, left alignment so, an integer 16 binary string is easy to get, but when we print the 16 binary content, we usually want a width of the left side of the equivalent of 0, what should be done? It's easy to add a
Integers to strings. Therefore, spritnf can replace ITOA in most cases.
For example:// Print the integer 123 into a string and save it in S.Sprintf (S, "% d", 123); // generate "123", you can specify the width, left fill space:Sprintf (S, "% 8d % 8d", 123,456 7); // generate: "123 4567", of course, it can be left aligned:Sprintf (S, "%-8d % 8d", 123,456 7); // generate: "123 4567"
You can also print the data in hexadecimal format:Sprintf (S, "% 8x
the string.Both printf and sprintf use formatted strings to specify the string format. Some strings starting with "%" are used inside the format string.Format specificationsThe function replaces the specifier with the variable at the corresponding position to generate a string that the caller wants.Format a numeric stringOne of the most common applications of sprintf is to print Integers to strings. Therefore, spritnf can replaceITOA. For example:// Print the integer 123 into a string and save
: "123 4567"
Of course, you can also align left:
Sprintf (S, "%-8d % 8d", 123,456 7); // generate: "123 4567"
You can also print the data in hexadecimal format:
Sprintf (S, "% 8x", 4567); // lowercase hexadecimal notation, with 8 width positions and right alignment
Sprintf (S, "%-8x", 4568); // in hexadecimal notation, the width occupies 8 positions and is left aligned.
In this way, the hexadecimal string o
parameter:Format the string.Both printf and sprintf use formatted strings to specify the string format. Some strings starting with "%" are used inside the format string.Format specificationsThe function replaces the specifier with the variable at the corresponding position to generate a string that the caller wants.Format a numeric stringOne of the most common applications of sprintf is to print Integers to strings. Therefore, spritnf can be replaced in most cases.ITOA. For example:// Print the
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.