#include<stdio.h>
#include<conio.h>
struct link
{
int data;
struct link*ptr;
};
typedef struct link node;
struct link1
{
int info;
struct link1*next;
};
typedef struct link1 node1;
int main()
{
int i,size;
node*start,*temp,*p;
int j,listsize;
node1*start1,*temp1,*k;
clrscr();
{
printf("enter the size of first list:\n"); /*creating first list*/
scanf("%d",&size);
printf("enter list:\n");
start=NULL;
for(i=0;i<size;i++)
{
if(start==NULL)
{
start=(node*)malloc(sizeof(node));
scanf("%d",&start->data);
start->ptr=NULL;
}
else
{
for(p=start;p->ptr!=NULL;p=p->ptr)
temp=(node*)malloc(sizeof(node));
scanf("%d",&temp->data);
temp->ptr=NULL;
p->ptr=temp;
}
}
printf("enter the size of second list:\n"); /*creating 2nd list */
scanf("%d",&listsize);
printf("enter list:\n");
start1=NULL;
for(j=0;j<listsize;j++)
{
if(start1==NULL)
{
start1=(node1*)malloc(sizeof(node1));
scanf("%d",&start1->info);
start1->next=NULL;
}
else
{
for(k=start1;k->next!=NULL;k=k->next)
temp1=(node1*)malloc(sizeof(node1));
scanf("%d",&temp1->next);
temp1->next=NULL;
k->next=temp1;
}
}
for(p=start;p!=NULL;p=p->ptr) /*concatenation of two lists*/
{
for(k=start1;k!=NULL;k=k->next)
{
temp->ptr=start1;
temp1->next=NULL;
}
}
printf("concatenated list is:\n");
for(p=start;p!=NULL;p=p->ptr)
printf("%d",p->data);
getch();
return 0;
}
}
it is giving me a warning when i compile this program that there is a "suspicious pointer conversion"....????
now i know that it must be somewhere in the concatenating part over there so plz let me know the problem area in my code here so that i can make the necessary changes...plz help me out!!!
what i am trying to do here is that im creating 2 lists suppose if the first list is 10 20 30 and the second list is 40 50 60 then concatenating them i should get...10 20 30 40 50 60
so that means that the address part of 3rd node of first list that is 30 should point to the first node of second list now and the pointer part should store 40 now in its address and so on.and then the last node that is 60 should have in its address part the NULL value...
but when i run this it is giving me some garbage value of several other digits...why?...
please help me out here!!!!