I'm new to C++ and running into a lot of sytax all the time.. I havn't been able to find a concrete answer to this in a while now. I'm trying to run this piece of code:
void test(char &testChar){ char B[3] = {"BB"}; testChar = B; } int main(int argc, const char * argv[]) { char A[3] = {"AB"}; test(A); std::cout << A; return 0; } I want to pass my Variable A to function test and have that function replace the content of A with the content of local variable B, and then print that out. How should this be done?
char&, and you cannot assign arrays to one another. Which C++ book are you using?int x = 5, y = 4; y = x;? You assignxtoy, which replaces the contents of theintwith that of another. What Christian cannot do is use assignment notation -- he is absolutely attempting to do that at the present time, as you can clearly see from his code, and it is this that I refer to.