Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C question

  • 29-11-2001 7:50pm
    #1
    Registered Users, Registered Users 2 Posts: 927 ✭✭✭


    ok, so i haven't used C in ages and as a result i'm a bit rusty.

    Basically i am generating psuedo-rando hex value and i want to pass them into a program 'findkey.exe'.

    Basically how can do i run the external programme ??


Comments

  • Registered Users, Registered Users 2 Posts: 347 ✭✭Static


    I think popen's your man. Open a pipe and fprintf to it.
    I think 8)


  • Closed Accounts Posts: 1 sphincter


    The easiest way, and it's fairly platform neutral would be
    to use system(), and pass the parameter on the command
    line. Copy/convert your number to a string, and:

    strcpy(command, "myotherprogramname ");
    strcat(command, myRandomNumberString);
    return = system(command);

    You can access parameters passed to your program via
    argc and argv, the implicit parameters of main(int argc, char **argv).

    An improvement on this would be to use one of the exec()
    variants - on a Unix platform, it'll cut down on the amount of
    processes that have to get created.

    Hope this helps.


  • Registered Users, Registered Users 2 Posts: 347 ✭✭Static


    Of course, be careful if "myRandomNumberString" is dynamically created by your program, you don't want to go exec'ing malicious input if you're not the one creating it. Check it. Also use strncat/strncpy.


  • Registered Users, Registered Users 2 Posts: 927 ✭✭✭decob


    Cheers, thanks Static/sphincter for the help.

    Static, yeah the numbers are being generated dynamically.


Advertisement