#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    101
    Rep Power
    0

    Why do you need CM arguments for exec()?


    Simple code for opening Internet explorer:

    Code:
    #include<stdio.h>
    #include<process.h> //like unistd.h
    
    int main()
    {
    
    	execl("C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe","C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe","hello world",NULL);
    	//getchar();
    	return 0;
    }
    This does open internet explorer but doesn't go directly to the page. Anyway, I'm asking why do I need any command line arguments but the first one? What's the use of the argument "hello world" when I put it there? All I see is when internet opens the text is on top of the bar.
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,379
    Rep Power
    1871
    > This does open internet explorer but doesn't go directly to the page.
    Perhaps you could try an actual URL.

    > Anyway, I'm asking why do I need any command line arguments but the first one?
    The prototype for execl is something like
    int execl(const char *path, const char *arg0, ...);
    The first parameter is the path to the program to be run.
    arg0 is typically (though not necessarily) the same as path.
    Then you have arg1, arg2 etc, until the NULL parameter marking the end of the arguments.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    If you're going to pass arguments to iexplore.exe, then shouldn't you learn what arguments iexplore.exe takes? RTFM anyone?

    From Windows Internet Explorer Command-Line Options:
    Code:
    iexplore.exe [ [ -embedding ] 
                   [ -extoff ] 
                   [ -framemerging ] 
                   [ -k ] 
                   [ -noframemerging ]
                   [ -nohangrecovery ]
                   [ -private ] ]
                 [ URL ]
    You are supposed to provide it with a URL. You did not. It didn't work. Gee, I wonder why. Maybe because you didn't provide it with a URL?

    And how do you pass an "argument" to a website? Certainly not through a command line argument. Look into the Common Gateway Interface (CGI). The "argument" will be the part after the question mark.

    If you don't even know how to compile a C program (which is what you kept insisting yesterday), then why are you trying to play with this problem?

IMN logo majestic logo threadwatch logo seochat tools logo