Hi,
i am having this problem with c structure pointers. this is snippet from a larger program in which i use temp* to assign values to different other pointers but whenever i update temp* it automatically updates the value of all other assigned pointers as well.
pointer b points to pointer temp and after assigning this whenever i change temp value it automatically changes the b value as well.
can anyone please help me on how i can perform this assigning with value instead of memory reference.
Thanks.
#include <iostream>
#include <list>
using namespace std;
struct node {
string data;
};
int main(){
node* temp;
node* b;
temp = new node;
temp->data = "heloo";
b = temp;
cout << "A:"<< temp->data << " : B:" << b->data << endl;
temp->data = "yyy";
cout << "A:"<< temp->data << " : B:" << b->data << endl;
}