M
michael
Hi All,
How do I pass a reference to a pointer and update the pointer in the
function? I have:
void goGetString(char *str){
string inString;
cin >> inString;
str = new char[inString.length()+1];
strcpy(str, inString.c_str());
cout << "String is " << str << endl;
}
int main(){
char *someStr;
goGetString(&*someStr);
cout << "String was " << someStr << endl;
}
why is someStr not changed ?
Thanks for your help
Michael
How do I pass a reference to a pointer and update the pointer in the
function? I have:
void goGetString(char *str){
string inString;
cin >> inString;
str = new char[inString.length()+1];
strcpy(str, inString.c_str());
cout << "String is " << str << endl;
}
int main(){
char *someStr;
goGetString(&*someStr);
cout << "String was " << someStr << endl;
}
why is someStr not changed ?
Thanks for your help
Michael