open URL using C program

This is a discussion on open URL using C program within the C Programming forums, part of the General Programming Boards category; Hi All, I was trying to open a url using a C program but unable to open My program is ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    32

    open URL using C program

    Hi All,
    I was trying to open a url using a C program but unable to open

    My program is
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    void main()
    { clrscr();
    
    	system("C:\Program Files\Internet Explorer\IEXPLORE.EXE  http://www.google.com");
    	getch();
    
    
    }
    result:

    Bad Commnad or filename


    Suggest me.....


    Thanks

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    You need to escape the back slashes,
    Code:
    system("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE  http://www.google.com");
    BTW, if you want to open a URL in the users default browser use ShellExecute() (See MSDN).

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    32
    Code:
    system("C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE  http://www.google.com");
    I tried with above system returns 0, but cant open any window....

    where Am going wrong....

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,012
    Try ShellExecute to open an URL. This will also open the URL in the default browser. Some people might get annoyed when you pop up an URL in IE rather than Firefox or Opera when they have one of those browsers set as default.
    There was also another thread with ShellExecute back some time on how to open a web page I think. You can check that too.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to open program twice
    By mysterio2099 in forum C++ Programming
    Replies: 7
    Last Post: 03-31-2006, 03:28 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 10:54 AM
  4. Replies: 1
    Last Post: 11-23-2001, 10:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21