IN the following C++ snippet, is a=b assigment possible ??:
unsigned int * a;
D3DCOLOR b[16];
a=(unsigned int)b;
Will this assignment copy all the elements of b array to a? Is the typecast fine?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First of all, it should have been:
More importantly, this just makes
apoint to contents ofb, and it does not copy it. If you want to copy arrays, you have to do it explicitly, for example with aforloop orstd::copy, that is if you don’t want to go with classes and stuff.Side note: to copy into
a, you need memory fora! You can do it either on the stack:or dynamically (for example with
new).