I am writinga palindrome checker widget.
I get one error:
pallindrome.cpp:37: error: 'lineEdit' was not declared in this scope
Here is the code for the main method
void palindrome::check_palindrome()
{
int rem,rem2,rem3,rem4,digit;
int place1,place2,place3,place4,place5;
digit=lineEdit.text();
rem= digit % 10000;
place1= (digit-rem)/10000;
rem2= rem % 1000;
place2= (rem-rem2)/1000;
rem3 = rem2 % 100;
place3= (rem2-rem3)/100;
rem4 = rem3 % 10;
place4= (rem3-rem4)/10;
place5=digit-(10000*place1+1000*place2+100*place3+10*place4);
if((place1==place5)&&(place2==place4))
{
msgbox.setText("number s a palindrome");
msgbox.exec();
}
void palindrome::check_palindrome()
{
int rem,rem2,rem3,rem4,digit;
int place1,place2,place3,place4,place5;
QMessageBox msgbox;
digit=lineEdit.text();
rem= digit % 10000;
place1= (digit-rem)/10000;
rem2= rem % 1000;
place2= (rem-rem2)/1000;
rem3 = rem2 % 100;
place3= (rem2-rem3)/100;
rem4 = rem3 % 10;
place4= (rem3-rem4)/10;
place5=digit-(10000*place1+1000*place2+100*place3+10*place4);
if((place1==place5)&&(place2==place4))
{
msgbox.setText("number s a palindrome");
msgbox.exec();
}
To copy to clipboard, switch view to plain text mode
I put the line lineEdit->text() in the UI file so I don't know why it is giving me this error.
I am followoing a similar logic to the last prolblem. The only thing that I might need to do is convert the
lineEdit to a number , if it isn't already done.
Bookmarks