I am trying to find a guide and even found this, but it didn't provide an answer. My question is how to initialize a C array in a constructor? Below I put a hypothetical example of what I think of doing, however I have no clue of whether it is ok but faulty, perfect, or simply there is something wrong and there would be a way to make it better.
class A{
private:
char* a;
int b;
public:
A(char*, int);
}
A::A(char* _a, int _b){
strcpy(a, _a);
b = _b
}
int main(){
A tempA;
char arr[50];
int c = 40;
strcpy(arr,"derp")
tempA = new A(arr,c)
return 0;
}
I have no C++ expert close to me at the moment so I would appreciate to receive as much feedback as possible. Also sorry if this is a duplicate question, but I really found nothing on this out there.