Thread: graph.h header file

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    5

    graph.h header file

    I am using a book entitled "An introduction to C programming" by David M Collopy which comes with a microsoft visual C++ 6.0 compiler. The author uses the header file "#include <graph.h>", however whenever I try and compile the programme I get an error message (fatal error C1083) which says that there is "no such file or directory". I have conducted a search for the file and have found it in my C drive under program files. If someone is familiar with this compiler I would be grateful if they tell me how I can get this programme to compile successfully (source code is included below).

    Many thanks

    Martin
    Code:
    /******************************************************************
    
    PRODUCTION OUTPUT: Load keyboard data into parallel arrays and
    print the contents of the arrays.
    
    Programme:	CHAP10A.C
    Author:		
    Date:		27.12.02
    Project:	Sample programme
    
    *******************************************************************/
    
    /*-----PREPROCESSING DIRECTIVE------------------------------------*/
    
    #include <stdio.h>
    #include <graph.h>
    
    /*-----FUNCTION PROTOTYPES----------------------------------------*/
    
    void LoadArrays(void);	//Load data into arrays
    void PrnArrays(void);	//Print data from arrays
    
    /*-----PROGRAMME SETUP--------------------------------------------*/
    
    /*>	   PROGRAMME VARIABLES										 <*/
    
    char sName [5][21];		//5 element 21 character array
    int iProd [5];			//5 element integer array
    
    /*------------------------------------------------------------------
    
      MAINLINE CONTROL
    
    -------------------------------------------------------------------*/
    
    main()
    {
    	_clearscreen(0);
    	//system("cls");
    	LoadArrays();
    	PrnArrays();
    	return 0;
    	//while(!kbhit());
    }
    
    /*------------------------------------------------------------------
    
      LOAD DATA INTO ARRAYS
    
    -------------------------------------------------------------------*/
    
    void LoadArrays(void)
    {
    	int iSub;		//Array subscript
    
    	for (iSub = 0; iSub < 5; iSub++)
    	{
    		printf("Enter the employee name %d: ", iSub + 1);
    		scanf(" %20 [^\n]", sName [iSub]);
    		fflush(stdin);
    
    		printf("Enter production %d: ", iSub + 1);
    		scanf("%d", iProd [iSub]);
    		fflush(stdin);
    	}
    
    	return;
    	//while(!kbhit());
    }
    
    /*------------------------------------------------------------------
    
      PRINT DATA FROM ARRAYS
    
    -------------------------------------------------------------------*/
    
    void PrnArrays(void)
    {
    	int iSub;		//Array subscript
    
    	printf("\nEMPLOYEE NAME			PRODUCTION");
    	printf("\n________________________________");
    
    	for (iSub = 0; iSub < 5; iSub++)
    	{
    		printf("\n%-20s		%2d", sName [iSub], iProd [iSub]);
    	}
    
    	return;
    	//while(!kbhit());
    }


    Code Tags added by Hammer

  2. #2
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    graph.h is intended for use in dos based apps as Salem stated. I have MSVC 1 which has graph.h for dos apps, but it invokes a graphics runtime library that MSVC 6 does not include; I'd suspect that you'd get an "unresolved external error" on __clearscreen. If you wish to include that file, then either give it the asbolute path or put it in your VC includes folder.

    program files\visual studio\vc98\include\ or whatever the folder is.... I forget.

    Code:
    #include "c:\mypath\graph.h"
    I doubt if it would work though without the runtime lib, but who knows.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    5
    Thank you for your help. I have included the file in the VC folder as you suggested, but although the compiler is now able to find graph.h it is generating the error messages below, so it appears it you were right about the runtime library.

    --------------------Configuration: chap10a - Win32 Debug--------------------
    Compiling...
    chap10a.c
    C:\Program Files\DevStudio\VC\INCLUDE\graph.h(15) : error C2282: 'BOOL' is followed by 'GraphInitializeApplication' (missing ','?)
    C:\Program Files\DevStudio\VC\INCLUDE\graph.h(18) : error C2282: 'HWND' is followed by 'CreateGraphWindow' (missing ','?)
    C:\Program Files\DevStudio\VC\INCLUDE\graph.h(21) : error C2146: syntax error : missing ')' before identifier 'hWnd'
    C:\Program Files\DevStudio\VC\INCLUDE\graph.h(21) : error C2501: 'hWnd' : missing decl-specifiers

    I can compile the programme successfully if I omit <graph.h> and replace -clearscreen(0) with system("cls"). However, the programme does not quite run as intended. When the data is being loaded into the arrays, under comments "load data into arrays", the cursor won't move directly from the line "Enter employee name" to "enter production" i.e If I type in name of Joe Bloggs and hit the return button I get a blank line. I can only proceed to "enter production" when I enter a character into the second (blank) line. I want to experiment substituting "fflush(stdin)". I have tried system("cls"), but this has the same effect. Is there alternative syntax for clearing the screen more effectively ?

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I can only proceed to "enter production" when I enter a character into the second (blank) line. I want to experiment substituting "fflush(stdin)".
    Here's a subsitute: never use it! Search the board for more on it. In short, never flush an input stream.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Casual Visitor
    Join Date
    Oct 2001
    Posts
    350
    Have you tried the author's web site for supplemental files? Often there will be libs and extra stuff that you can download to work with the book's examples. It's worth a look.
    I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  2. Need help understanding Header Files
    By Kaidao in forum C++ Programming
    Replies: 11
    Last Post: 03-25-2008, 10:02 AM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. Making a LIB file from a DEF file for a DLL
    By JMPACS in forum C++ Programming
    Replies: 0
    Last Post: 08-02-2003, 08:19 PM
  5. Replies: 6
    Last Post: 04-02-2002, 05:46 AM