what is the following code doing, particularly in the *strcat1 function???
(1)explain to me the reason for two while loops,
(2)why does the first have just *p2 : no assignments or logical operators??
(3)and why does the second have just ; on a line???
(4)what does ++p2 do as compared to ++(*p2) ??
sorry so many questions, but I figure that in order to have this sink in and for me to get what is going on I need to know what each part of the code is saying/doing.
Code:
#include <stdio.h>
#include <string.h>
char *strcat1(char *strDest, char *strSource)
{
char *p1 = strSource, *p2 = strDest;
while (*p2)
++p2;
while (*p2++ = *p1++)
;
return strDest;
}
main()
{
char s1[] = "abc", s2[] = "def";
printf("Result is: %s\n", strcat1(s1, s2));
return 0;
}