Trouble with excelp() (I'm very new to this)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jazon
    New Member
    • Apr 2007
    • 5

    Trouble with excelp() (I'm very new to this)

    I'm using C and attempting to pass something like this:

    Code:
    ret = execlp( "somefile", "somefile", num1, num2, (char *)0 );
    Of course, that doesn't work.

    This, on the other hand, works fine:

    Code:
    ret = execlp( "somefile", "somefile", argv[1], argv[2], (char *)0 );
    That'd be great, but I can't just pass argv to it. Before it gets there I have to convert them to ints, do a little work on them, then pass them. How do I do this?? If I convert them back to char they don't pass correctly.

    Say, somefile simply says

    Code:
    cout << argv[1] << endl;
    If I'm lucky it'll print some random number, that I'm assuming is what's in some random address space.

    Any help is greatly appreciated!!
  • ashitpro
    Recognized Expert Contributor
    • Aug 2007
    • 542

    #2
    Originally posted by jazon
    I'm using C and attempting to pass something like this:

    Code:
    ret = execlp( "somefile", "somefile", num1, num2, (char *)0 );
    Of course, that doesn't work.

    This, on the other hand, works fine:

    Code:
    ret = execlp( "somefile", "somefile", argv[1], argv[2], (char *)0 );
    That'd be great, but I can't just pass argv to it. Before it gets there I have to convert them to ints, do a little work on them, then pass them. How do I do this?? If I convert them back to char they don't pass correctly.

    Say, somefile simply says

    Code:
    cout << argv[1] << endl;
    If I'm lucky it'll print some random number, that I'm assuming is what's in some random address space.

    Any help is greatly appreciated!!
    Convert num1 and num2 to char * i.e. make them into string

    Comment

    • jazon
      New Member
      • Apr 2007
      • 5

      #3
      Originally posted by ashitpro
      Convert num1 and num2 to char * i.e. make them into string

      Thanks a bunch! Works perfectly with sprintf!

      Comment

      Working...