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

**Code:** `ISO C++ forbids comparison between pointer and integer` · **Category:** C/C++ · **Seen on:** C/C++, GCC, Clang

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

## 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*?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/cpp/pointer-integer-comparison)
