Nov 25, 2008 at 4:08pm UTC
In the code snippet given below
void linklist::cancelticket(int del_class,int del_brth)
{
linklist* Loc2;
linklist* Locp2;
findb(del_class,del_brth,&Loc2,&Locp2);
if (Loc2==NULL) {
cout<<"Berth unreserved!\n";
goto Exit;
}
Loc2->data.f_name="Cancelled Berth";
Loc2->data.l_name="";
Loc2->data.age=0;
cout<<"Ticket cancelled! Have a nice day.\n";
Exit:
}
I got the error as 'lvalue required' in the lines that I have made bold. I am unable to correct it. Can anyone help me?
Last edited on Nov 25, 2008 at 4:10pm UTC
Nov 25, 2008 at 4:39pm UTC
We have a little thing called else to avoid using goto.
Are you sure cancelticket() should be a method of linklist? It doesn't seem to use this
for anything.
More to the point, though, I'd need to see the definitions of f_name and l_name.
Last edited on Nov 25, 2008 at 6:01pm UTC
Nov 26, 2008 at 2:09pm UTC
Actually I know little about this code since I am asking this on behalf of my friend...so anyway
I will try to use else and see what happens also
char f_name[30],l_name[30];
is the definitions of f_name and l_name. It is defined inside a class.
Nov 26, 2008 at 2:27pm UTC
You can't assign a string literals to a char arrays declared like that. What you probably want to do is a bit-wise copy of the string to the array f_name and l_name point to.
You'll need strcpy() for that:
strcpy(Loc2->data.f_name,"Cancelled Berth");
And so on.
Nov 26, 2008 at 3:48pm UTC
Thankyou....
It works now...
Thankyou very much. we had almost given up on that code.