Node* common(Node *head1, Node *head2)
{
string *ptr = new string;
string *ptr1 = new string;
int count = 0; //count for head1
int count1 = 0; //count for head2
cout << endl;
Node *t = head1;
while (t != NULL)
{
ptr[count] = t->data;
t=t->next;
cout << ptr[count] << endl;
count++;
}
Node *s = head2;
while (s != NULL)
{
ptr1[count1] = s->data;
s=s->next;
cout << ptr1[count1] << endl;
count1++;
}
for (int i = 0; i < count; i++)
{
for (int j = 0; j < count1; j++)
{
if (ptr[i] == ptr[j])
{
cout << ptr[i] << endl;
}
}
}
return 0;
}
Unhandled exception at 0x77883450 (msvcr120d.dll) in Project38.exe: 0xC0000005: Access violation writing location 0xABABABAB.
when i was debugging it i am getting this break opeartion again and again help me sort this error.
Updated (I know this is shortcut but the mothod above was not working)Tell me when u got solution :
Node* common(Node *head1, Node *head2)
{
string ptr1[6];
int count = 0;
cout << endl;
Node *t = head1;
Node *p = head2;
Node *a = head2;
while (a != NULL)
{
a = a->next;
count++;
}
for (int i = 0; i < count; i++)
{
ptr1[i] = p->data;
p=p->next;
}
while (t != NULL)
{
for (int i = 0; i < count; i++)
{
if (t->data == ptr1[i])
{
cout << t->data << endl;
}
}
t = t->next;
}
return 0;
}
Updated (I know this is shortcut but the mothod above was not working)Tell me when u got solution : and thanks to john and paul and others for helping me out +1000 Reputations for them i hope i can be like u one day... Unhandled exception at 0x77883450 (msvcr120d.dll) in Project38.exe: 0xC0000005: Access violation writing location 0xABABABAB. when i was debugging it i am getting this break opeartion again and again help me sort this error. Updated (I know this is shortcut but the mothod above was not working)Tell me when u got solution :
User contributions licensed under CC BY-SA 3.0