Thank you for answering.
the code works great now, but i am still confused about not assigning the pointer _settingname a pointee. you have indicated that i do not need to include the & sign during,
testing.setname(&_name) but is this not similar to stating *_settingname=&_name.
but not having it would come like this *_settingname=name;
wouldn't the program crash, because i am trying to assign a value to what the pointer is pointing to but the pointer is not pointing to anything.
i wrote this and tried it and the program does end up crashing.
(i understand that there is something i am misunderstanding here, since when i did what you said the code works great, i am a bit confused of why not including the &)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
using namespace std;
int main()
{
int *p;
int i;
cin>>i;
*p=i;
cout<<*p<<endl;
return 0;
}
|
Also, why do i need to use strcpy, can i not follow the pointer, and get whats in the box that the pointer is pointing to, and assign it to name.
Thank you