Reputation: 23
I found a way using a Terminal Command for that purpose: xdg-open http://www.google.com
But how can I do it from my code? Thanks.
Upvotes: 0
Views: 5601
Reputation: 11
#include <stdlib.h>
int main()
{
char *URL;
URL = "xdg-open http://google.com";
system(URL);
return 0;
}
Upvotes: 1
Reputation: 1
#include <stdlib.h>
int main()
{
char *URL;
URL = "chromium http://localhost/image/index.php";
system(URL);
return 0;
}
Upvotes: 0
Reputation: 1302
Easiest way is to include stdio.h
and use the system()
call to call xdv-open
.
If you want to be able to change the url, try:
#include "stdio.h"
int main(int argc, char ** argv){
char url[128]; //you could make this bigger if you want
scanf("%s",url); // get the url from the console
char call[256];
strcpy(call, "xdg-open "); // web browser command
strcat(call, url); // append url
system(call);
return 0;
}
Upvotes: 0
Reputation: 3069
If the executable for Firefox (or Chrome, etc) is in your path, you can get away with:
system("firefox http://www.google.com");
If not, try:
system("C:\\Program Files\\Mozilla\\Firefox.exe http://www.google.com");
Upvotes: 0
Reputation: 22435
I don't know C, but it seems like you just need to call said shell script via C. So after a quick google search (hint hint), you could probably call something along the lines of
system("xdg-open http://www.google.com");
Basically you just want a function that can execute a shell script
Upvotes: 1