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'.
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 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
charwith a double-quoted string literal - Comparing
std::string[i]to a string instead of a char - Comparing a pointer to
0/1instead ofnullptror a value - Using
=in a condition and comparing a pointer with an int
⚡ Quick fix
- Use single quotes for characters:
c == 'y' - Use
std::stringand==for text,strcmp(a, b) == 0for C strings - Compare pointers with
nullptr
Detailed fix by platform
C++
if (answer == "yes")works whenansweris astd::string; for a singlecharuse'y'
Code examples
Character vs string literal
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 stringHow to diagnose
- Operand types — One side char and the other string literal?
- Quotes — Single or double quotes?
- 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:
Similar errors
- call of overloaded is ambiguous C++: error: call of overloaded 'f(int)' is ambiguous
- comparison of integers of different signs C/C++: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' [-Wsign-compare]
- does not name a type C++: error: 'string' does not name a type
Most viewed in C/C++
- terminate called after throwing an instance of C++: terminate called after throwing an instance of 'std::out_of_range' — what(): vector::_M_range_check
- double free or corruption C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped)
- undefined reference to C/C++: undefined reference to `function' — collect2: error: ld returned 1 exit status
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 15 Oct 2026