Thread: Inventory records

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Registered User
    Join Date
    Oct 2005
    Posts
    63
    I fixed the hfPtr, it was the others that I thought were declared in the prototype. Its now giving me an error that says writePr is being used without having been initialized but I thought that this had initialized it.
    Code:
    /* create formated text for printing */
    void textFile( FILE *readPtr )
    {
    	FILE *writePtr; /* hardware.txt file pointer */
    
    	/* create hardwareData with default information */
        struct hardwareData hardware = { 0, "", 0,0.0 };
    
        /* fopen opens file; exits if file cannot be opened */
    	if ((hfPtr = fopen( "hardware.dat", "rb+" )) == NULL ) {
    		printf( "File could not be opened.\n" );
    	} /* end if */
    	else{ 
    		rewind( readPtr ); /* sets pointer to begining of file */
    		fprintf( writePtr, "%-6s%-10s%-8s%-8s\n",
    			"Record#", "Tool name", "Quantity", "Cost" );
    p.s. feof is what is used in my book so thats why I used it.
    Last edited by jsbeckton; 11-17-2005 at 08:37 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. reading a file into a block
    By mickey0 in forum C++ Programming
    Replies: 19
    Last Post: 05-03-2008, 05:53 AM
  3. Replies: 26
    Last Post: 06-15-2005, 02:38 PM
  4. Counting number from a random file
    By kamisama in forum C Programming
    Replies: 42
    Last Post: 02-22-2005, 05:16 PM
  5. display records held in a struct
    By colinuk in forum C Programming
    Replies: 3
    Last Post: 02-02-2005, 07:51 AM