Hello everybody!

This is new area for me. Structures and File I\O.
I need to create structure date that will contain the following elements:

Code:
struct date {
   int month;
   int day;
   int year;
}reordDate;

struct date blankDate = {0,0,0};
This is the date that is initialized to zero. This structure is nested into the one that is bigger and most crucial here:

Code:
struct invent{
	char partId[6+1];
	char partDesc[25+1];
	double unitPrice;
	int quanOnHand;
	int reordPoint;
	int reordQuant;
	struct reordDate;
	int delFlag;
}item;
Now, after I have this created I need to copy test data that will be created in text file.

Test data:

Part ID Description Unit Price QOH ROP ROQ

Data goes here.

C program will read this data and populate a struct that meets specifications in invent structure.

This is the part I don't understand:

Code:
char ch, lastch = ' ';
char tempLine[40];
char bufferLine[80];

typedef struct{
           char partid [6+1];
           long recoffst;
}INDEX;
INDEX indxpt [100];
Why is lastch is declared with the ' ' space character. I understand that tempLine and bufferLine are arrays where read data will be temporary stored. typedef struct with only two elements and partid that is repeated from the first structure. What is the purpose of this structure? Variable for typedef structure is index, and now I have array of structures that is equal to 100 of these. I don't understand typedef structures, is that different than when you declare struct plus tag and elements and variable. I tried to find this answer in the book but it is very confusing.

These structures were declared before main function so that means it is global for whole program. I understand that.

I need to write the structure to a binary file opened in w+ mode:

Code:
main()
{
   if((inPut = fopen("part.txt","r"))!= NULL)
     if((outPut = fopen("invent.dat","wb+"))!= NULL)
       if (fgets(bufferLine, 80, inPut)==NULL)
	goodrd = 0;
	   else
	     puts(bufferLine);
}
Here my indentation could be bad, but I don't know which of these are nested.