simple site opener
I saw very complicated programs on net to open a site but i want to make a simple c++ program to open a site.
Here is my code but it does not open the site.Also how do i make it so it opens in a particular browser only?
1 2 3 4 5 6 7 8
|
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
fstream fs;
fs.open("www.google.com");
}
|
Last edited on
This is actually something fairly easy to do cross-platform:
1 2 3 4 5 6 7
|
#ifndef INVOKE_BROWSER_HPP
#define INVOKE_BROWSER_HPP
#include <string>
int invoke_browser( const std::string& URL );
#endif
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <cstdlib>
#include <string>
#ifdef __APPLE__
#include <TargetConditionals.h>
#endif
int invoke_browser( const std::string& URL )
{
#ifdef _WIN32
return std::system( ("start \"\" " + URL).c_str() );
#elif defined(__APPLE__) && TARGET_OS_MAC
return std::system( ("open " + URL + " &").c_str() );
#else
return std::system( ("xdg-open " + URL + " &").c_str() );
#endif
}
|
thanks guys.
Topic archived. No new replies allowed.