Many time throughout running c++ regime you obtain comparison errors. Sometimes it will certainly be iso c++ forbids comparison between pointer and also integer or occasionally you will get iso c++ forbids comparison in between pointer and also integer <-fpermissive>. Below we will see once these kind of c++ compiler error occurs and also how to solve these iso c++ forbids comparison between pointer and also integer errors from c++ program.

You are watching: Iso c++ forbids comparison between pointer and integer [-fpermissive]

1. Iso c++ forbids comparison in between pointer and also integer


Output:

*

Here during string comparison girlfriend are getting compilation errors. “error: ISO C++ forbids comparison between pointer and integer <-fpermissive>”

SOLUTION for ERROR:

if(str==’ab’), below str is const char* type. I beg your pardon is range of character.Here ‘ab’ is consider as creature value. Ideally it must be as constant string value.Because of solitary quote it is considered as integer value.So for comparison you must use double quote “ab”. And also declare it as string variable.Now you can compare making use of strcmp(str, “ab”) or utilizing str == “ab”.


Output:

*

2. Error: ISO C++ forbids comparison between pointer and also integer <-fpermissive>


#include making use of namespace std;int func(int i, int j) int val = 1; if (val > func) return (val+1); return val;int main() int val = func(3,6); return 0;
Output:

*

SOLUTION for ERROR:

If you view if problem if(val > func), then right here we have actually by wrong given function name i m sorry has different datatype climate integer value.

So ours comparison is wrong. Whenever any type of comparison is wrong friend will get this error. Ideally here we should compare v some creature value.

See more: " Your Grace Still Amazes Me Sheet Music By Phillips Craig, Your Grace Still Amazes Me Sheet Music In C Major


Here we have removed function name and comparing it through Integer value. Currently that error will be resolved.

CONCLUSION:

Whenever you room getting any error comparable to ISO C++ forbids comparison between pointer and also integer <-fpermissive>, Then examine that compare condition. You will get to know that comparison condition is mismatch v two various data kind of variables. For fixing c++ forbids comparison error you simply need come compare similar kind of variables in conditions. I hope provided two examples will be helpful for your to find out your code issue. If you like this article then please inspect other c++ related info in provided website. Happy Coding !!