Check if the given string is IPv4 or IPv6 or Invalid

  #include using namespace std;  bool checkIPv4(string s){            int cnt = 0;          for (int i = 0; i < s.size(); i++) {        if (s[i] == '.')            cnt++;    }          if (cnt != 3)        return false;          vector tokens;          stringstream check1(s);    string intermediate;          while (getline(check1,                   intermediate, '.')) {        tokens.push_back(intermediate);    }      if (tokens.size() != 4)        return false;              for (int i = 0; i < tokens.size(); i++) {        int num = 0;                  if (tokens[i] == "0")            continue;          if (tokens[i].size() == 0)            return false;          for (int j = 0;             j < tokens[i].size();             j++) {            if (tokens[i][j] > ‘9’                || tokens[i][j] < '0')                return false;              num *= 10;            num += tokens[i][j] - '0';              if (num == 0)                return false;        }                  if (num > 255 || num < 0)            return false;    }      return true;}  bool checkHex(string s){        int n = s.length();          for (int i = 0; i < n; i++) {        char ch = s[i];                          if ((ch < '0' || ch > ‘9’)            && (ch < 'A' || ch > ‘F’)            && (ch < 'a' || ch > ‘f’)) {            return false;        }    }      return true;}  bool checkIPv6(string s){            int cnt = 0;      for (int i = 0; i < s.size();         i++) {        if (s[i] == ':')            cnt++;    }          if (cnt != 7)        return false;          vector tokens;          stringstream check1(s);    string intermediate;          while (getline(        check1,        intermediate, ':')) {        tokens.push_back(intermediate);    }      if (tokens.size() != 8)        return false;              for (int i = 0;         i < tokens.size(); i++) {          int len = tokens[i].size();          if (!checkHex(tokens[i])            || len > 4 || len < 1) {            return false;        }    }    return true;}  void checkIPAddress(string s){        if (checkIPv4(s))        cout