Can this be done? we'll say for example I wanted to go to www.cprogramming.com, can the program bring me to it from inside?
Printable View
Can this be done? we'll say for example I wanted to go to www.cprogramming.com, can the program bring me to it from inside?
I'm sure there is similar for *nix.Code:#include <windows.h>
int main()
{
ShellExecute(NULL, "open", "http://www.cprogramming.com",
NULL, NULL, SW_SHOWNORMAL);
return 0;
}
cool!! that works for a hardwared website, but can you do it for a user defined one too?
To modify sly's code...very easy.
Code:string go;
cin >> go;
ShellExecute(NULL, "open", go.c_str(),NULL, NULL, SW_SHOWNORMAL);
return 0;
Hmmm, thanks, em, when I do that I get this error:
U:\countdown.cpp(11) : error C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)
here's the code:
Code:#include <stdio.h>
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
string go;
cin >> go;
ShellExecute(NULL, "open", go.c_str(),NULL, NULL, SW_SHOWNORMAL);
return 0;
}
Works fine for me.
By the way don't mix includes like that.
Code:#include <cstdio>
#include <iostream>
#include <windows.h>
To use the string type you must also [code[#include <string>[/code]