Article View: alt.comp.lang.learn.c-c++
Article #144C++ problem - help
From: Victor
Date: Mon, 05 Apr 1999 00:00
Date: Mon, 05 Apr 1999 00:00
51 lines
1955 bytes
1955 bytes
I have been asked to design a project to determine whether a word is a
palindrome or not (btw a plaindrome is a word that is the same backwards ie
noon).
I have been able to run the program successfully with some words but it
doesn't seem to like the word 'deer' and other words with the same middle
letters. It thinks that it is a palindrome which is not true.
Could somebody help please.
Thanks for your time . . .
#include <condefs.h>
#include "Project1io.h"
#pragma hdrstop
//--------------------------------------------------------------------------
-
USELIB("Project1io.LIB");
//--------------------------------------------------------------------------
-
#pragma argsused
int main(int argc, char **argv)
{
int Front;
int Back;
char Palindrome;
AnsiString InputString;
InputString = ReadStringPr("Enter your non-empty string for testing");
Front = 1;
Back = Length(InputString);
while (Front < Back)
{
if (InputString[Front] == InputString[Back])
Palindrome = true;
else
Palindrome = false;
Front = Front + 1;
Back = Back - 1;
}
if (Palindrome == true)
WriteString("Yes, it is a palindrome");
else
WriteString("No it is not a palindrome");
getchar();
return 0;
}
Technical Details
Message-ID:
<7eatvr$p1g$1@barcode.tesco.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 114592,61f8664269971e91,start X-Google-Attributes: gid114592,public X-Google-Thread: 10d4ba,61f8664269971e91,start X-Google-Attributes: gid10d4ba,public X-Google-Thread: 109fba,61f8664269971e91,start X-Google-Attributes: gid109fba,public From: "Victor" <bushmills@tesco.net> Subject: C++ problem - help Date: 1999/04/05 Message-ID: <7eatvr$p1g$1@barcode.tesco.net> X-Deja-AN: 462942218 Organization: Little ( if any ) X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++