Skip to content

Instantly share code, notes, and snippets.

@Lomeli12
Created October 16, 2014 22:31
Show Gist options
  • Save Lomeli12/ef5c2ea3e6c41c5b27ac to your computer and use it in GitHub Desktop.
Save Lomeli12/ef5c2ea3e6c41c5b27ac to your computer and use it in GitHub Desktop.
How
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <cstring>
using namespace std;
int main(int argc, char* argv[]) {
string google = "https://www.google.com/search?q=";
string keyWord = "how";
if (argc > 0) {
string srch = keyWord + "+";
for (int i = 1; i < argc; i++) {
srch = srch + argv[i];
if (i != (argc - 1)) srch = srch + "+";
}
string full = "xdg-open " + google + srch;
char * cstr = new char [full.length() + 2];
strcpy(cstr, full.c_str());
system(cstr);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment