Code:
typedef struct
{
int age;
string name;
} structure;
int functionCall( map< char* , structure* >* map_o )
{
map< char* , structure* >* map_op;
map_op = map_o;
structure msgData_sp;
msgData_sp.name="You";
msgData_sp.age=12;
msgMap_o->insert( map< char* , structure* >::value_type( "Me" , &msgData_sp ) );
// i tried to print the values of the map here.. and it was ok
return 0;
}
int main()
{
map< string , structure* > msgMap_o;
functionCall( &msgMap_o );
map< string , structure* >::iterator iter_o = msgMap_o.begin();
cout << "MainKey: " << iter_o->first << endl;
cout << "Line: " << (iter_o->second)->LineContractNumber_i << endl;
// the key was printed but
// when i tried to print the values.. seg fault
}
Can you help me with this simple program.. Ways in order for main to receive the changes main by functionCall.
Comment