Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/151.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 错误:ISO C++;禁止指针和整数[-fppermissive]之间的比较|_C++_Char_Integer - Fatal编程技术网

C++ 错误:ISO C++;禁止指针和整数[-fppermissive]之间的比较|

C++ 错误:ISO C++;禁止指针和整数[-fppermissive]之间的比较|,c++,char,integer,C++,Char,Integer,这是验证密码的代码。正在检查输入字符串的数字、特殊字符、字符串长度以及大小写字符。 将字符串元素与特殊字符进行比较的for循环的特定块会产生此错误。我尝试将这些特殊字符初始化为char变量以进行比较,但错误仍然存在 char k='@'; char n='#'; char m='$'; for(i=0; i<l; i++) { if(password[i]==k || password[i]==n || password==m)

这是验证密码的代码。正在检查输入字符串的数字、特殊字符、字符串长度以及大小写字符。 将字符串元素与特殊字符进行比较的for循环的特定块会产生此错误。我尝试将这些特殊字符初始化为char变量以进行比较,但错误仍然存在

char k='@';
char n='#';
char m='$';
for(i=0; i<l; i++)
        {
            if(password[i]==k || password[i]==n || password==m)     
            {
                counts++;
            }
        }
这是密码

    #include <iostream>
    #include<string.h>

    using namespace std;

    int main()
    {
     char password[20];
     char k='@';
     char n='#';
     char m='$';
     int i,j,l,countd=0,counts=0,countl=0,countu=0;
     cout<<"enter a password with following conditions :\n1. There should be atleast one digit. \n2. 
 there should be atleast one of #, @, $";
    cout<<"3. password should be between 6 to 20 characters \n4.there should be more uppercase 
letters than lower case\n";
cout<<"5. Should start with uppercase and end with lowercase";

do
{
    countd=0,counts=0,countl=0,countu=0;
    cout<<endl<<"ENTER PASSWORD :";
    cin.getline(password,20);
    l=strlen(password);
    if(l>20 || l<6)
    {
        cout<<"password length should be between 6 to 20 characters \n";
    }
    if(islower(password[0]))
    {
        cout<<" first letter should be uppercase \n";
    }
    if(isupper(password[l-1]))
    {
        cout<<" last letter should be lowercase \n";
    }


    for(i=0; i<l; i++)
    {
        for(j='0'; j<='9'; j++)
        {
            if(password[i]==j)
            {
                countd++;

            }

        }
    }
    if(countd<1)
    {
        cout<<" password should contain atleast one digit \n";
    }

    for(i=0; i<l; i++)
    {
        if(password[i]==k || password[i]==n || password==m)     //char k='@'; char n='#'; char m='$'; |56|error: ISO C++ forbids comparison between pointer and integer [-fpermissive]|
        {
            counts++;
        }
    }


    if(counts<1)
    {
        cout<<"password should contain atleast one of the three special character \n";
    }


    for(i=0; i<l; i++)
    {
        for(j='A'; j<='Z'; j++)
        {
            if(password[i]==j)
            {
                countu++;
            }
        }
    }
    for(i=0; i<l; i++)
    {
        for(j='a'; j<='z'; j++)
        {
            if(password[i]==j)
            {
                countl++;
            }
        }
    }
    if(countu<countl)
    {
        cout<<"number of uppercase letters should be more than lowercase \n";
    }

}

while((countu<countl) || (counts<1) (isupper(password[l-1])) || (islower(password[0])) || l>20 || l<6 || (countd<1));

cout<<endl<<"password accepted/validated "<<endl;


return 0;
}
#包括
#包括
使用名称空间std;
int main()
{
字符密码[20];
字符k='@';
字符n='#';
字符m='$';
int i,j,l,countd=0,counts=0,countl=0,countu=0;
不能这条线

if(password[i]==k || password[i]==n || password==m) 
应该读

if(password[i]==k || password[i]==n || password[i]==m) 

请注意上一个术语中缺少的括号。

如果幸运的话,请创建一个,您的编译器还应该给您一个列指针,它将告诉您忘记了三个索引括号中的哪一个!欢迎使用stack overflow!遗憾的是,此问题不够详细,无法为您提供任何有意义的帮助。请编辑您的问题以包含一个小括号该问题的重复性不好的示例,包括样本输入、首选输出和您迄今为止尝试过的代码。为什么希望能够有意义地比较指针和整数?感谢大家的回答。问题在于索引括号和
(计数)
if(password[i]==k || password[i]==n || password==m) 
if(password[i]==k || password[i]==n || password[i]==m)