I guess I am confused for some reason on how to initialize a char pointer value. Maybe I am overthinking it. I have this in a header file called Login.h char *arg1;
I got a warning that the member variable is not initialized in this constructor. So in Login.cpp I put:
Login::Login() { // TODO Auto-generated constructor stub arg1 = (char *)malloc(50); //arg1 = new char(); //arg1 = nullptr; } What is the difference between:
arg1 = (char *)malloc(50); arg1 = new char(50); When I try the code below, I get incompatible type.
arg1 = 'A'; I guess I am confused on initializing a pointer vs a normal variable
Should I just do this?
arg1 = nullptr; Hoping someone can clarify this for me, thanks.
std::string arg1{};if not thenchar *arg1 = new char[50];(don't forget, you are then responsible for callingdelete[] arg1;when done witharg1)