Strlen (P):
- Can calculate the length of P pointing to a string (starting with the current position of P), and does not contain the terminating character ' \ n ';
- P can be declared as char* P or char p[], both of which can be calculated correctly strlen.
sizeof (P):
- sizeof is an operator, a non-function, whose value is determined at compile time, so when P is declared as a pointer to a type, sizeof is not able to determine the size of the content when it compiles, so it returns the size of the pointer type itself;
When P is declared as an array of type, sizeof determines the size of the content at compile time, so it returns the occupied capacity of the array;
Strcat (P1,P2) and strcpy (P1,P2)
Same point:
- P1 must be a pointer to a content that can be changed, such as Char p1[]
- When P1 is currently pointing to a terminating character ('% '), it is directly connected with the P2 content or overwritten at the current position of the P1 and thereafter
Different points:
- When P1 currently points to a character other than the terminating character (' P2 '), Strcat automatically connects the contents of the P2 to the location of the terminating character and thereafter, strcpy overwrites the current point with P1 content.
strlen sizeof strcat strcpy Difference