这是一个语法错误,但我没有找到它?

时间:2018-03-27 17:48:31

标签: c++

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
char a[27]=      {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' '};
char A[27]= {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' '};
string U[27]= {"AAAAA","AAAAB","AAABA","AAABB","AABAA","AABAB","AABBA","AABBB","ABAAA","ABAAB","ABABA","ABABB","ABBAA","ABBAB","ABBBA","ABBBB","BAAAA","BAAAB","BAABA","BAABB","BABAA","BABAB","BABBA","BABBB","BBAAA","BBAAB"," "};
char choiceNum;
while (true)
    {
cout<<"Choose what do you want to do  today"<<endl<<"1-cipher "<<endl<<"2-decipher"<<endl<<"3-If you End what you want"<<endl;
cin>>choiceNum;
cin.ignore();
string message, newMessage, message2;
int i,k, j ;
if (choiceNum=="1")
{
    cout<<"Enter your message to cipher ya man-.-"<<endl;


        newMessage="";
        getline(cin,message);

        for(i=0 ; i<message.length() ; i++)

        {
            for (j=0 ; j<27 ; j++)
            {
                if (message[i]==a[j]|| message[i]==A[j] )
                {
                    newMessage=newMessage+U[j];
                }

            }
        }
        cout<<newMessage<<endl;
    }


if (choiceNum=="2")
{
    cout<<"Enter your message to decipher ya man-.- :"<<endl;


        newMessage="";
        message2="";
        getline(cin,message);
        for(i=0 ; i<message.length() ; ++i)
        {
            if (message[i]=='a' || message[i]=='A')
            {
                message[i]='A';
            }
            else if (message[i]=='b' || message[i]=='B')
            {
                message[i]='B';
            }


        }

        for(k=0 ; k<message.length() ; ++k)
        {
            message2=message2+message[k];

            for (j=0 ; j<27 ; ++j)
            {

                if (message2==U[j])
                {

                    newMessage=newMessage+A[j];
                    message2="";
                }
            }
        }


        cout<<newMessage<<endl;

}
if (choiceNum=="3")
        {
            cout<<"End";
            break;
        }

          }



return 0;
  

|| ===构建文件:&#34;没有目标&#34; in&#34;没有项目&#34; (编译器:未知)=== |   \ Baconian cipher.cpp ||在函数&#39; int main()&#39;:   \ Baconian cipher.cpp | 25 |错误:ISO C ++禁止指针和整数之间的比较[-fpermissive] |   \ Baconian cipher.cpp | 49 |错误:ISO C ++禁止指针和整数之间的比较[-fpermissive] |   \ Baconian cipher.cpp | 91 |错误:ISO C ++禁止指针和整数之间的比较[-fpermissive] |   || ===构建失败:3个错误,0个警告(0分钟,5秒(秒))=== |

}

1 个答案:

答案 0 :(得分:1)

在C ++中'"代表完全不同的东西。

这是一个char字符:

'x'

这是const char*字符串:

"x"

您无法使用"x"char==之类的内容进行比较,但您可以与'x'进行比较。