ISO C++ forbids comparison between pointer and integer C/C++ Origin: Application & API Last updated 15 Oct 2026

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

You compared a string literal or pointer with a character or integer — typically ch == "y" instead of ch == 'y'.

Exact message you may see ISO C++ forbids comparison between pointer and integercomparison between pointer and integercomparison between pointer and zero character constantordered comparison of pointer with integer zeroresult of comparison against a string literal is unspecified
Seen on: C/C++ GCC Clang

Meaning

In C and C++ "y" is a const char[2] (a pointer), while 'y' is a single char. Comparing them mixes a pointer and an integer. For strings use std::string with ==, strcmp for C strings, and single quotes for one character.

Common causes

  • Comparing a char with a double-quoted string literal
  • Comparing std::string[i] to a string instead of a char
  • Comparing a pointer to 0/1 instead of nullptr or a value
  • Using = in a condition and comparing a pointer with an int

⚡ Quick fix

  1. Use single quotes for characters: c == 'y'
  2. Use std::string and == for text, strcmp(a, b) == 0 for C strings
  3. Compare pointers with nullptr

Detailed fix by platform

C++

  1. if (answer == "yes") works when answer is a std::string; for a single char use 'y'

Code examples

Character vs string literal

cpp
char c = 'y';
// if (c == "y") {}            // error: ISO C++ forbids comparison between pointer and integer
if (c == 'y') {}               // OK

std::string s = "yes";
if (s == "yes") {}             // OK: std::string compares with a C string

How to diagnose

  1. Operand types — One side char and the other string literal?
  2. Quotes — Single or double quotes?
  3. Container — Is it std::string or char*?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

call of overloaded is ambiguous — C++: error: call of overloaded 'f(int)' is ambiguous (C/C++)call of overloaded is…comparison of integers of different signs — C/C++: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' [-Wsign-compare] (C/C++)comparison of integer…does not name a type — C++: error: 'string' does not name a type (C/C++)does not name a typeinvalid conversion from — C++: error: invalid conversion from 'const char*' to 'char*' [-fpermissive] (C/C++)invalid conversion fr…narrowing conversion — C++: error: narrowing conversion of 'x' from 'int' to 'char' inside { } [-Wnarrowing] (C/C++)narrowing conversionno match for 'operator' — C++: error: no match for 'operator<<' (operand types are 'std::ostream' and 'X') (C/C++)no match for 'operato…template argument deduction/substitution failed — C++: error: template argument deduction/substitution failed / couldn't deduce template parameter (C/C++)template argument ded…ISO C++ f…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.