Why in the below written code we can not assign strA to strB and as the pointer pA holds address of pointer pB then address should have been copied on assignment of pA to pB and strB should have contain the value same as strB.
#include <stdio.h>
char strA[80] = "A string to be used for demonstration purposes";
char strB[80];
int main(void)
{
char *pA; /* a pointer to type character */
char *pB; /* another pointer to type character */
puts(strA); /* show string A */
pA = strA; /* point pA at string A */
puts(pA); /* show what pA is pointing to */
pB = strB; /* point pB at string B */
putchar('\n'); /* move down one line on the screen */
pB=pA;
strB=strA;
puts(strB); /* show strB on screen */
puts(strA);
return 0;
}
strAandstrBaren't string variables. there is no such thing asstring variablein C. they are arrays. an array can't be assigned to another array.