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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Lvalue required" error when trying to find palindrome

Status
Not open for further replies.

aztech1977

Programmer
Mar 25, 2008
2
GB
Hi guys, trying to use Borland C++ to create a program to read in a string value to find out if it's a palindrome. Lots of examples online but none that are too useful. My code is as below but i keep getting the errors (as seen at the bottom of the page).
On the code i have marked out which lines the errors refer to.
I'm a newbie can you help, what am i doing wrong?
//--------------------------------------------------------
int main(int argc, char* argv[])
{
AnsiString Line;
int Front;
int Back ;
bool Palindrome(char *, int, int);
//Pseudo-Code
WriteString("Enter the string to be tested");
Line = ReadStringPr("Enter the string to be tested");
Front = 1;
Back = Length(Line);
Palindrome = true; <---------------ERROR (1)
while ((Front < Back) & (Palindrome = true)); <---------------ERROR (2 & 3)
{
if (Line[Front] == Line[Back])
{
Palindrome = false; <---------------ERROR (4)
}
else
{
Front = Front + 1;
Back = Back - 1;
} //ifend
} //loopend
WriteString("Line");
if (Palindrome = true) <---------------ERROR (5)
{
WriteString("is a palindrome");
}
else
{
WriteString("is not a palindrome");
}
getchar();
return 0;
}

ERROR MESSAGES
------------------------
1. [C++ Error] SCAM1TST.cpp(25): E2277 Lvalue required
2. [C++ Error] SCAM1TST.cpp(26): E2277 Lvalue required
3. [C++ Warning] SCAM1TST.cpp(26): W8019 Code has no effect
4. [C++ Error] SCAM1TST.cpp(30): E2277 Lvalue required
5. [C++ Error] SCAM1TST.cpp(39): E2277 Lvalue required
 
Palindrome is the name of a bool function you've declared - you can't reuse the name as a variable.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top