Reputation: 23
I want my c++ code to open a url.However all the threads online promote using ShellExecute with an already specified url. My code requires the user to input the url and the program must then open it in a browser so the url is in the form of a string. Much Appreciated.
Upvotes: 1
Views: 9832
Reputation: 107
I believe this should to the trick for you, of course, if you are using Windows:
std::cout<<"Enter the link: ";
std::string link;
std::cin>>link;
ShellExecute(NULL, "open", link.c_str(), NULL, NULL, SW_SHOWNORMAL);
Upvotes: 3
Reputation: 1433
Something like that :
std::string myUrl;
std::cin >> myUrl;
system(std::string("start " + myUrl).c_str());
?
Upvotes: 2