🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.tools.mfc
Article #91

Re: spawnvp does not work

#91
From: Jeremy Paiz
Date: Mon, 19 Apr 2004 03:15
83 lines
3272 bytes
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" <ehab_aziz2001@yahoo.com> wrote in message
news:7ecaee57.0404161602.525f7bec@posting.google.com...
I wrote that program but spawnvp dows not call the exe files
hello1,hello2!!!

#include <stdio.h>
#include <conio.h>
#include <process.h>

//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++);
 }
Technical Details
Message-ID: <0vHgc.1822$e4.1709@newsread2.news.pas.earthlink.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!d539159e!not-for-mail
References: <7ecaee57.0404161602.525f7bec@posting.google.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1138df,d0fc32548bb83a0a
X-Google-Attributes: gid1138df,public
X-Google-Thread: 114592,d0fc32548bb83a0a
X-Google-Attributes: gid114592,public
X-Google-Thread: fa69e,d0fc32548bb83a0a
X-Google-Attributes: gidfa69e,public
X-Google-ArrivalTime: 2004-04-18 20:15:08 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!stamper.news.atl.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!d539159e!not-for-mail
Reply-To: "Jeremy Paiz" <jpaiz_news@earthlink.net>
From: "Jeremy Paiz" <jpaiz_spam@earthlink.net>
Newsgroups: comp.os.ms-windows.programmer.tools.mfc,alt.comp.lang.learn.c-c++,borland.public.cpp.borlandcpp
References: <7ecaee57.0404161602.525f7bec@posting.google.com>
Subject: Re: spawnvp does not work
Lines: 85
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
Message-ID: <0vHgc.1822$e4.1709@newsread2.news.pas.earthlink.net>
Date: Mon, 19 Apr 2004 03:15:08 GMT
NNTP-Posting-Host: 67.38.7.244
X-Complaints-To: abuse@earthlink.net
X-Trace: newsread2.news.pas.earthlink.net 1082344508 67.38.7.244 (Sun, 18 Apr 2004 20:15:08 PDT)
NNTP-Posting-Date: Sun, 18 Apr 2004 20:15:08 PDT
Organization: EarthLink Inc. -- http://www.EarthLink.net