Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error msg: "invalid lvalue in assignment"

Status
Not open for further replies.

mike00800

Technical User
Joined
Nov 7, 2007
Messages
1
Location
IE
Hi everyone, this is my first time using the forum.

I get the error msg "invalid lvalue in assignment". The line it refers to is as follows:

for(counter1=counter-5;counter1<=counter+5;counter1++){if(CONTACTS[counter1][0]=j && CONTACTS[counter1][1]=j_voisine){
counter2=counter2+1; }
}

'counter' and 'counter1' have been declared outside main() and the code above is called within main(). I have used 'counter' as follows:

if(CONTACTS[counter-1][0]!=0 && (CONTACTS[counter-1][0]!=1052 || CONTACTS[counter-1][0]!=1053))

and there was no problems.

Has anybody encountered anything like this before?

Thanks,

Mike
 
First, here is how the code should look if you want Humans to be able to read it properly:
Code:
for ( counter1 = counter - 5; counter1 <= counter + 5; counter1++ )
{
    if ( ([COLOR=red]CONTACTS[counter1][0] = j[/color]) && ([COLOR=red]CONTACTS[counter1][1] = j_voisine[/color]) )
    {
        counter2 = counter2 + 1;
    }
}
Should the parts in red be assignment operators or equality operators?

How are each of these variables defined?
 
Scattering the same post on multiple forums generally annoys the heck out of people who help on multiple forums.

For starters, it means you didn't choose your forum carefully.



--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top