writing program from a book

From: hpy_awad_at_yahoo.com (ehab_aziz2001_at_yahoo.com)
Date: 01/28/04


Date: 28 Jan 2004 10:33:24 -0800

I wrote that program from a book that my compile that program
correctly under C++ compiler but I got those errors for compiling
under unix !!

Errors-
--------
part10_iti_r01_ch10_verbo_menu_driven_programs.c: In function `main':
part10_iti_r01_ch10_verbo_menu_driven_programs.c:6: warning:
declaration of `argc' shadows a parameter
part10_iti_r01_ch10_verbo_menu_driven_programs.c:7: warning:
declaration of `argv' shadows a parameter
part10_iti_r01_ch10_verbo_menu_driven_programs.c:22: syntax error
before '{' token

Program-
--------
#include <stdio.h>
//part10_iti_r01_ch10_verbo_menu_driven_programs.c

main (argc,argv)
{
int argc;
char *argv[50];
{
   int option;
   do
   {
      //Display menu
      display_menu();

     //Initite appropriate program or exit
     if (option!=7) //exit
     call_program(option,argv);
   }
  while (option!=7);
}
display_menu()
{
system("clear");
printf ("\n TV Rental system");
printf ("\n ----------------");
printf("\n\n 1 Set up new customer");
printf("\n\n 2 Change existing customer record");
printf("\n\n 3 Add new customer record");
printf("\n\n 4 Delete customer record");
printf("\n\n 5 Print customer bills");
printf("\n\n 6 display a customer record");
printf("\n\n 7 Exit");
}

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

call_program(opt,argv)
int opt;
char *argv[];
{
    switch(opt)
    {
      case 1: spawnvp(0,"a.obj",argv);
              delay();
              break;

      default:printf("\nError");
              delay();
    }
}

delay()
{
int i;
for (i=0;i<=20000;++i);
}



Relevant Pages

  • writing program from a book
    ... I wrote that program from a book that my compile that program ... int option; ... printf("\n\n 2 Change existing customer record"); ...
    (comp.unix.programmer)
  • writing program from a book
    ... I wrote that program from a book that my compile that program ... int option; ... printf("\n\n 2 Change existing customer record"); ...
    (comp.unix.solaris)
  • Re: GCC difference in size of long int on Suse SLES9 / Suse Professional 10.0
    ... The kernel uses printf() with 'long int', ... I can't compile 'on-the-fly'. ... clashing with the hardware and any libs that you interact with. ... platform types build up their own int types. ...
    (comp.os.linux.development.apps)
  • Re: Im a C++ programmer, and Relfs X.CPP is good.
    ... >> and it doesn't compile either. ... home.cpp:93: implicit declaration of function `int fclose' ... You cannot change to your home directory through an external ...
    (comp.lang.lisp)
  • Re: Im a C++ programmer, and Relfs X.CPP is good.
    ... >> and it doesn't compile either. ... home.cpp:93: implicit declaration of function `int fclose' ... You cannot change to your home directory through an external ...
    (comp.unix.programmer)