Thread: No errors but stiil doesn't work

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

    No errors but stiil doesn't work

    I tried what you suggested and it got rid of the errors but
    it doesn't run the program.
    The #define made since.
    How come it still want work. I am trying hard to understand this.
    If this was Cobol, I wouldn't have any trouble calling another program.

    Code:
    /*
                              Menu
    */
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h> 
    #include "carpet.h"
    #define FILENAME "c:\\mydocu~1\\pa17.exe" //Inserted 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");
    	fopen("c:\\mydocu~1\\pa17.exe", "r"); \\Correct this
    	printf("%d\n", b);
    	
    }//end function2
    void function3(int c)
    {
    	system("cls");
    	printf("%d\n", c);
    }//end function3

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,994
    > I wouldn't have any trouble calling another program.
    Now you say what you want - what was with the .rpt last time

    > fopen("c:\\mydocu~1\\pa17.exe", "r");

    should be

    system ( "c:\\mydocu~1\\pa17.exe" );
    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.

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

    Still doesn't work

    Salem:

    Maybe it's me but It's still not calling or bringing up the menu.
    The rpt was a report that I was trying to bring up and then I thought I would just execute the program.
    Is there anything that I should include in the other program to make it work?

    I do appreciate your help.
    Please forgive my ignorance. The semester is over and our professor did not cover this part and I would really like to learn it.

    sketchit

    [code]

    /*
    Menu
    */

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include "carpet.h"
    #define FILENAME "c:\\mydocu~1\\pa17.exe"
    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");
    system( "c:\\mydocu~1\\pa17.exe" );//Made change

    printf("%d\n", b);

    }//end function2
    void function3(int c)
    {
    system("cls");
    printf("%d\n", c);
    }//end function3
    Imagination at Work

  4. #4
    Registered User jasrajva's Avatar
    Join Date
    Oct 2001
    Posts
    99

    Smile

    hi

    u've '#DEFINE'ed your FILENAME so why dont you use it
    try
    system(FILENAME);

    if your prev code doesnt work then this wont either though bcoz once the preprocessor has done its job both will be identical neway i've known stranger(seemingly) things to happen so try it out ok
    neway its a shame using a define and then not using it

    pardon me for rambling thats the way i am
    jv

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,994
    > The rpt was a report that I was trying to bring up and then I thought I would just execute the program.
    You see, now I'm really confused.

    Is this file a program which you run, or just a data file?

    Because passing a data file to system() is just as bad as trying to fopen a .exe file.

    Or does pa17.exe produce the .rpt file, which you then want to display?

    Now which is it to be?
    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.

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

    Thanks JV but it still not working

    Jv:

    The defines make a lot of since so I did change it
    and it still does not work.
    Imagination at Work

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

    RE:pa17.exe

    Salem:

    I want this menu to call PA17.exe that contains PA17.rpt.
    PA17.exe is in a different folder located in mydocument.
    Sorry for the confusion and I hope that this clears up what I am trying to do.
    Also, when I enter 1 it gives me a bad command error.

    Thanks

    Code:
    /*
                              Menu
    */
    
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h> 
    #include "carpet.h"
    #define FILE_NAME "c:\\mydocu~1\\pa17.exe" 
    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");
    	system(FILE_NAME);//fixed this
    	printf("%d\n", b);
    	
    }//end function2
    
    void function3(int c)
    {
    	system("cls");
    	printf("%d\n", c);
    }//end function3
    Imagination at Work

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

    Salem, It works!!!!!!!!!!!!!!

    Smack self upside da head.
    How stupid can one be!
    That stupid one would be me.
    I forgot to put and additional //file//in the sequence//.

    Thanks alot for your help and patientance.
    Please forgive my stupity.
    Imagination at Work

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with some errors in my game
    By Mikalio in forum C Programming
    Replies: 4
    Last Post: 12-04-2008, 03:16 PM
  2. Replies: 3
    Last Post: 11-17-2008, 12:36 PM
  3. How properly inherit from template?
    By 6tr6tr in forum C++ Programming
    Replies: 118
    Last Post: 04-25-2008, 04:30 AM
  4. executing errors
    By s0ul2squeeze in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2002, 01:43 PM