Error comparison between distinct pointer types char and int lacks a cast -fpermissive
This error occurs when comparing two pointers that have different data types. In this case, a char* pointer is being compared to an int* pointer without a cast.
To fix this error, you need to cast one of the pointers to the same data type as the other pointer before comparing them. For example, if you want to compare a char* pointer to an int* pointer, you can cast the char* pointer to an int* pointer before comparing them:
char* charPointer;
int* intPointer;
if ((int*)charPointer == intPointer) {
// do something
}
Alternatively, you can change the data type of one of the pointers to match the other one:
char* charPointer;
int* intPointer;
int* newIntPointer = (int*)charPointer;
if (newIntPointer == intPointer) {
// do something
}
Note that casting between different pointer types can be dangerous and may lead to unexpected results if not done correctly. Make sure you understand the implications of casting before using it in your code
原文地址: https://www.cveoy.top/t/topic/hbdK 著作权归作者所有。请勿转载和采集!