error regarding lvalue

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
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
We have a little thing called else to avoid using goto.


We also have a thing called return or exit to end the function at any point.
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.
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.
Thankyou....

It works now...

Thankyou very much. we had almost given up on that code.
Topic archived. No new replies allowed.