struct node
{
char str[10];
int val;
node *next;
};
void main()
{
clrscr();
node *head=NULL;int cnt=0;
cout<<"Continue... [Y/N]";char ch;cin>>ch;
while(ch!='n')
{
node *temp;
cout<<"Str= ";cin>>temp->str;
cout<<"val= ";cin>>temp->val;
temp->next=head;
head=temp;
cnt++;
cout<<"Continue... [Y/N]";cin>>ch;
}
node *temp1;
temp1=head;
while(temp1!=NULL)
{
cout<<temp1->str<<" ";
cout<<temp1->val<<endl;
temp1=temp1->next;
}
getch();
}
Plz help me out....... i have created a linklist each node having two values integer val and char str.. integer value is printing bt i cant print my str value thru this statment "cout<<temp1->str" rather it is printing a grabage value.