Redirecting to a webpage in c++ -
i making program in c++, in web link there when type input or press enter redirect me link have entered. example if have 3 options , choose option a, program redirect me link in option a.
here's sample:-
#include<iostream> #include<stdlib.h> using namespace std; int main() { system("color b1"); int choice; cout << "menu" << endl; cout << "1. pasta" << "\n"; cout << "2. cold drink" << "\n"; cout << "your choice (1-2)" << "\n"; cin >> choice; if(choice == 1) { cout << "thanks" << "\n"; //here want url , when choose 1 //will direct me url } else if(choice == 2) { cout << "thanks" << "\n"; // , here also... } else { return 0; } }
please help. thanks
in windows desktop programs can use shellexecute api open
operation open url default application (generally web browser).
shellexecute(null, l"open", l"https://example.com", nullptr, nullptr, sw_shownormal);
store apps can not use shellexecute
@ all, can use uwp launchuriasync.
task = windows::system::launcher::launchuriasync( ref new windows::foundation::uri("https://example.com"));
the various other platforms have own api's. in general want find , use them , not assume particular browser executable on path preventing users using or installing non-default location (or getting broken updates, etc.).
Comments
Post a Comment