C++ Error: ISO C++ Forbids Comparison Between Pointer and Integer [-fpermissive]

15,973

Solution 1

"Y", "y", "n", and "N" are C-style strings, which are null-terminated character arrays. When attempting to compare them, they degenerate to pointers to const char. On the other hand, inputy is declared as int. This is the origin of your comparison between pointer and integer errors.

To fix the issue, compare inputy against characters instead of strings: 'Y', 'y', 'n', and 'N' (note the single quotes, rather than double quotes).

Solution 2

You have another problem. You've declared int inputy; but you are trying to read a character by doing scanf("%c", &inputy);. The format string %c does not match the data type of &inputy. If you want to read a character you should use the correct type for the input variable:

char inputy;

scanf("%c", &inputy);
Share:
15,973
Admin
Author by

Admin

Updated on June 27, 2022

Comments

  • Admin
    Admin about 2 years

    I am a beginner C++ Programmer With Very little knowledge about C++. I Have Been Creating a Program on The IDE and Compiler: Dev-C++ 5.6.3. I have run into this error: ISO C++ Forbids Comparison Between Pointer and Integer [-fpermissive]. I don't know what it means.

  • M.M
    M.M almost 10 years
    Also a change needs to be made, either inputy be a char, or scanf("%c" not be used
  • Mike DeSimone
    Mike DeSimone almost 10 years
    Ah yes, the confusion caused by the fact that so many "character" functions in C use int to pass or return the character.
  • Mike DeSimone
    Mike DeSimone almost 10 years
    Come to think of it, if running on a little-endian platform, and if the memory used by inputy was initialized to 0 by some means, then correct behavior will be observed even though the pointer is pointing to the wrong type (because the byte the pointer points to is the lowest-order byte of the int). Definitely "undefined behavior" as far as the language is concerned.