Thread: How do you call a program from a menu?

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    35

    How do you call a program from a menu?

    I have searched this board without any luch and unfortunatly my C book does not give an example of calling another program from a menu.

    Can someone steer me in the right direction?
    I'm in the dark on this this one. I would like to gain the knowledge on this one.

    Thanks for any help you can provide.

    Code:
    
    /*
                              Menu
    */
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h> 
    #include "carpet.h"
    #include "c:\mydocu~1\pa17.rpt" <---The compiler screams at this
    void function1( int);
    void function2( int);
    void function3( int);
    main()
    {
    	void (*f[3]) ( int) = {function1, function2, function3};
    	int choice;
        printf("0 = Carpet Information Data Entry\n");
    	printf("1 = Generate Reports\n");
    	printf("2 = Utilities\n");
    	printf("3 = End Program\n");
    	scanf("%d", &choice);
    
    	while (choice >= 0 && choice < 3)
    	{
    		(*f[choice]) (choice);
    		
    	    printf("0 = Carpet Information Data Entry\n");
    	    printf("1 = Generate Reports\n");
    	    printf("2 = Utilities\n");
    		printf("3 = End Program\n");
    	    scanf("%d", &choice);
    	}//end while loop
    	printf("Program has terminated\n");
    	return 0;
    }
    void function1(int a)
    {
    	system("cls");
    	printf("%d\n", a);
    	printf("%d\n", carpetCharge1);
    
    }//end function1
    void function2(int b)
    {
    	
    	system("cls");
                    fopenf(c:\mydocu~1\pa17.rpt", "rb"); <--                                                                This doesn't work either
    	printf("%d\n", b);
    	
    }//end function2
    void function3(int c)
    {
    	system("cls");
    	printf("%d\n", c);
    }//end function3
    Imagination at Work

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,662
    > #include "c:\mydocu~1\pa17.rpt" <---The compiler screams at this
    Probably because it doesn't contain any C code.

    Can't imagine why you would want to include it, since you read it later

    Perhaps you were trying
    #define FILENAME "c:\\mydocu~1\\pa17.rpt"
    Note the use of \\

    > fopenf(c:\mydocu~1\pa17.rpt", "rb");
    fopen("c:\\mydocu~1\\pa17.rpt", "rb");
    or
    fopen(FILENAME, "rb");
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to get RSSI value, send to sensor, sensor receive package, repackage it?
    By techissue2008 in forum Networking/Device Communication
    Replies: 1
    Last Post: 03-04-2009, 10:13 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 07:18 AM
  4. a program that will call an execute but with arguments
    By what3v3r in forum C++ Programming
    Replies: 3
    Last Post: 01-19-2006, 09:44 PM
  5. Is it possible to call a java program in C?
    By xilum68 in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2003, 01:26 AM