elispop122003 wrote On 2008-10-29 10:37 +0800:
> this is what I have so far
> 
> #include <iostream>
> #include <string>
> #include "aStack.h"
> #include "AQueue.h"
> 
> using namespace std;
> 
> bool match(char, char);
> bool isValid(char);
> 
> int main(){
>   char ch;
>   char chL, chR;
>   aStack S;
>   AQueue A;
>   int count = 0;
>   bool err = false;
> 
>   while((ch=cin.get())!= EOF){
>     cout << ch;  //Echo back data
>     if(ch!= '\n')
>     {
>       if(!isValid(ch))
>       {
>         ch = "";
"" indicated a string with only one element '\0' and prototype of *ch* is 
*char*. then compile error occurs
u may try this: ch = 0x0;
correct me if i'm wrong

regards
tomas

>         S.push(ch);
>         A.Enqueue(ch);
>       }
>       else
>       {
>         S.push(ch);
>         A.Enqueue(ch);
>         count++;
>       }
>     }
> 
>     while(count > 0)
>     {
>       S.pop(chL);
>       A.Dequeue(chR);
>       count--;
>       if(!match(chL, chR))
>         err = true;
>     }
>   if(err == true)
>     cout << "Not a valid pack palindrome." << endl;
>   else
>     {
>       cout << "Palindrome is valid" << endl;
>       err = false;
>     }
>   }
>   return 0;
> }
> 
> bool match(char chL, char chR){
>   if(chL == chR)
>     return true;
>   else
>     return false;
> }
> 
> bool isValid(char ch){
>   if((ch>= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
>     return true;
>   else
>     return false;
> }
> 
> My problem comes when I try to get rid of the punctuation. I get this
> error:
>      project3.cpp:29: error: invalid conversion from 'const char*' to
> 'char'
> If someone could help me I would greatly appreciate it.
> 
> 
> --- In [email protected], Rajath N R <[EMAIL PROTECTED]> wrote:
>> Hi,
>>  check this pice of code 
>>
>>
>> [EMAIL PROTECTED] ~]$ cat test.c
>>
>> #include <stdio.h>
>>
>> #define PALINDROME 0
>> #define NOT_PALINDROME 1
>>
>> main()
>> {
>>         char buff[512];
>>
>>         printf("Enter a string: ");
>>         scanf("%s", buff);
>>
>>         if (palindrome(buff) == PALINDROME) {
>>                 printf("String is palindrome\n");
>>         }
>>         else {
>>                 printf("String is not a palindrome\n");
>>         }
>>
>> }
>> int palindrome(char *ptr)
>> {
>>         int strbeg = 0, strend = 0;
>>
>>         strend = strlen(ptr) - 1;
>>         while ( strbeg == strend || strbeg < strend) {
>>                 if (ptr[strbeg] != ptr[strend])
>>                         return (NOT_PALINDROME);
>>
>>                 strbeg++;
>>                 strend--;
>>         }
>>         return (PALINDROME);
>> }
>>
>>
>> Thanks & Regards,
>>
>> Rajath N R

Reply via email to