Şöyle bir URL’niz varsa:
snippet.cpp
std::string myURL = "https://subdomain.example.com/api/test";Boost::URL kullanarak ondan host adını ayrıştırabilirsiniz (en az Boost 1.81.0 gerekir, önceki boost sürümlerinde Boost.URL yoktur). Şunu kullanarak:
snippet2.cpp
boost::urls::url_view url(myURL);
std::string host = url.host();
std::cout << host << std::endl; // "subdomain.example.com" yazdırır
Tam örnek:
urlhost.cpp
#include <string>
#include <iostream>
#include <boost/url.hpp>
int main() {
std::string myURL = "https://subdomain.example.com/api/test";
boost::urls::url_view url(myURL);
std::string host = url.host();
std::cout << host << std::endl; // "subdomain.example.com" yazdırır
}Şunu kullanarak derleyin:
build_urlhost.sh
g++ -o urlhost urlhost.cpp -lboost_urlIf this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow