Thursday, April 21, 2016

Assigning one array to another array c++

Hello I am beginner in c++ , can someone explain to me this



char a[]="Hello";

char b[]=a; // is not legal


whereas,



char a[]="Hello";

char* b=a; // is legal


If a array cannot be copied or assigned to another array , why is it so that it is possible to be passed as a parameter , where a copy of the value passed is always made in the method



void copy(char[] a){....}

char[] a="Hello";

copy(a);

No comments:

Post a Comment