ISO C forbids comparison between pointer and integer [-fpermissive]

时间:2022-07-22
本文章向大家介绍ISO C forbids comparison between pointer and integer [-fpermissive],主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

错误代码: S = “a##c”;

if(S[i] == "#"){
    if(s.length()!=0)
        s.pop_back();
}

异常:ISO C forbids comparison between pointer and integer [-fpermissive] 意思是:指针和整数比较出错;禁止指针和整数进行比较。 S[i]是字符,”#”表示一个字符串的首地址。

改正:

if(S[i] == '#'){//字符之间相互比较
    if(s.length()!=0)
        s.pop_back();
}