I am trying to check if ip address is in range by doing an and operation with the net mask , this code is giving me the following error :
invalid conversion from ‘const char*’ to ‘uint32_t {aka unsigned int}’ [-fpermissive]
I am a beginner in c++ is there any solution to this?
int main() {
uint32_t ip = "192.168.2.1";
// value to check
uint32_t netip = "192.168.2.0"; // network ip to compare with
uint32_t netmask = "255.255.255.0"; // network ip subnet mask
if ( (netip & netmask) == (ip & netmask)) {
// is on same subnet...
std::cout << "On the same subnet" << std::endl;
} else {
// not on same subnet...
std::cout << "Not on the same subnet" << std::endl;
}
}