Current location - Education and Training Encyclopedia - Graduation thesis - C language programming questions, to achieve the connection of two strings,
C language programming questions, to achieve the connection of two strings,
The strings in C all point to the first character of the string with a char pointer, and the end of the string is indicated by' \0'(ASCII code value is 0).

while (*p 1! = ' \ 0 ')p 1++; //Indicates that p 1 The pointer will skip to the next character before reaching the end of the string.

After the above loop, the pointer p 1 must point to the end of the string.

then

while (*p2! ='\0'){*p 1=*p2,p 1++; P2++/ This is where P2 is copied to p 1 from beginning to end. Since p 1 has pointed to the end of the string, it is equivalent to connecting the string.