// Szstring. cpp: defines the entry point of the console application.
//
# Include "stdafx. H"
# Include <iostream>
# Include <cassert>
Using namespace STD;
Int _ tmain (INT argc, _ tchar * argv [])
{
Char const * pstr = "10 45"; // in order to test the effect of a space, replace 3 with a space.
Char const * pstr2 = pstr;
Cout <"strlen (pstr) =" <strlen (pstr) <Endl;
Assert (strlen (pstr) = 5 );
/*
For (; * pstr! = '\ N'; pstr ++) // The end character is incorrect! Prints this is a string and other content of the internal code segment.
{
Cout <* pstr;
}
*/
// Correct syntax: All the characters to be pointed to except the null characters are true values.
While (* pstr)
{
Cout <* pstr;
Pstr ++;
}
Cout <"*** finish" <Endl; // to display the end of the string, add the * sign. The result shows 10 45 **** finish
// Another incorrect method
While (* pstr2 ++)
{
Cout <* pstr2; // insert a breakpoint here for debugging and observe pointer changes * pstr2 => 0 ('\ 060')> ''> 4> 5> 0, last pstr2 = ""
}
Cout <"*** finish" <Endl; // The result is displayed as 0 45 *** finish (the empty character value is ASCII 0 (it is '\ 0' rather than' \ 060 ') and occupies a blank space)
Cout <'\ 077' <0 <'\ 0' <' \ 60' <Endl; // The ASCII code of the character 0 is 48, and the octal value is 060. Output :? 0 0 line feed
: System ("pause ");
Return 0;
}
/* Note: output characters using ASCII codes directly
For example, check the ASCII code table and find the question mark character (?) The ASCII value of is 63,
Then we can convert it into an octal value: 77, and then use '\ 77' To Represent '? '. Because it is octal,
Therefore, it should be written as '\ 077', but because C and C ++ do not allow the use of a slash plus a 10-digit number to represent characters,
Therefore, the value 0 can be left empty.
With ultraedit32, you can press Alt + press enter at the cursor to view the code value of the current character.
*/