spawnvp does not work - Programmer

This is a discussion on spawnvp does not work - Programmer ; I wrote that program but spawnvp dows not call the exe files hello1,hello2!!! #include #include #include //Tv Rental system menu version 1 int user_selection(); void display_menu(); void call_program(int option,char *argv[]); int main(int ,char *argv[]) { int option; do { display_menu(); ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: spawnvp does not work

  1. spawnvp does not work

    I wrote that program but spawnvp dows not call the exe files hello1,hello2!!!

    #include
    #include
    #include

    //Tv Rental system menu version 1
    int user_selection();
    void display_menu();
    void call_program(int option,char *argv[]);
    int main(int ,char *argv[])
    {
    int option;
    do
    {
    display_menu();
    option=user_selection();
    if (option!=7) //Exit
    call_program(option,argv);
    }
    while (option!=7);
    return 0;
    }


    void display_menu()
    {
    clrscr();
    printf("1 hello1");
    printf("\n2 hello2");
    printf("\n3 exit");
    }

    int user_selection()
    {
    int opt;
    printf("\n Enter required option(1-3) : ");
    scanf("%1d",&opt);
    return (opt);
    }

    void call_program(int opt,char *argv[])
    {
    void delay();
    switch(opt)
    {
    case 1:
    spawnvp(0,"hello1.exe",argv);
    delay();
    break;
    case 2:
    spawnvp(0,"hello2.exe",argv);
    delay();
    break;
    default:
    printf("\n incoreect input");
    delay();
    exit(0);
    }
    }
    void delay()
    {
    int i;
    for (i=0;i<20000;i++);
    }

  2. Re: spawnvp does not work

    you haven't assigned 'opt' a value. it's value is undetermined, but i'm
    willing to bet it's not 1 or 2. seeing how you're asking the user to input
    a digit, you will most likely want to get the user request by calling
    "fgetc" or something similar. basically you'd replace the "scanf" call with
    the "fgetc" call. the return value is the "int" value of the character
    input, so you'll either have to convert it to the actual digit value or
    change the "switch" statement to include the character case values, such as:

    case '1':
    ...

    case '2':
    ...


    "hpy_awad@yahoo.com" wrote in message
    news:7ecaee57.0404161602.525f7bec@posting.google.c om...
    I wrote that program but spawnvp dows not call the exe files
    hello1,hello2!!!

    #include
    #include
    #include

    //Tv Rental system menu version 1
    int user_selection();
    void display_menu();
    void call_program(int option,char *argv[]);
    int main(int ,char *argv[])
    {
    int option;
    do
    {
    display_menu();
    option=user_selection();
    if (option!=7) //Exit
    call_program(option,argv);
    }
    while (option!=7);
    return 0;
    }


    void display_menu()
    {
    clrscr();
    printf("1 hello1");
    printf("\n2 hello2");
    printf("\n3 exit");
    }

    int user_selection()
    {
    int opt;
    printf("\n Enter required option(1-3) : ");
    scanf("%1d",&opt);
    return (opt);
    }

    void call_program(int opt,char *argv[])
    {
    void delay();
    switch(opt)
    {
    case 1:
    spawnvp(0,"hello1.exe",argv);
    delay();
    break;
    case 2:
    spawnvp(0,"hello2.exe",argv);
    delay();
    break;
    default:
    printf("\n incoreect input");
    delay();
    exit(0);
    }
    }
    void delay()
    {
    int i;
    for (i=0;i<20000;i++);
    }



  3. Re: spawnvp does not work

    I tried
    > case '1':
    > ...
    >
    > case '2':
    > ...
    >
    >


    It has no effests .!!!

+ Reply to Thread