Code:
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include "C:\Documents and Settings\10111260\My Documents\CrtUtil.h"
FILE *inPut, *outPut;
struct date{
int month, day, year;}reordDate;
struct date blankDate = {0,0,0};
struct invent{
char partId[6+1];
char partDesc[25+1];
double unitPrice;
int quanOnHand;
int reordPoint;
int reordQuant;
struct reordDate;
int delFlag;
}item;
int i, j, goodrd = 1;
int delFlag;
char ch, lastch = ' ';
char tempLine[40];
char bufferLine[80];
typedef struct{
char partid [6+1];
long recoffst;
}INDEX;
INDEX indxpt [100];
main()
{
if((inPut = fopen("C:\\Documents and Settings\\10111260\\My
Documents\\part.txt","r"))!= NULL)//CHECKING IF I HAVE INPUT FILE
if((outPut = fopen("C:\\Documents and Settings\\10111260\\My
Documents\\invent.dat","wb+"))!= NULL)//CHECKING IF I HAVE OUTPUT FILE
{if (fgets(bufferLine, 80, inPut)==NULL)//IF GETS = NULL goodrd IS
FALSE
goodrd = 0;
else
puts(bufferLine);//ELSE bufferLine = THE LINE READ
while(goodrd)//WHILE goodrd IS TRUE
{lastch = ' ';//lastch = NULL
reordDate = blankDate;
delFlag = 0;//delFlag is set to 0
for( i = 0, j = 0; lastch != ','; i++, j++)
{sscanf(&bufferLine[i], "%c",&ch);//reading the bufferLine
character by character
if(ch != ',')//if ch is not equal to ','
tempLine[j] = ch;//the character is send to tempLine
lastch = ch;}//lastch = character read
for( j = 0; lastch != ','; j++, i++)
{sscanf(&bufferLine[i], "%c",&ch);
if(ch != ',')
tempLine[j] = ch;
lastch = ch;}
for( j = 0,; lastch != ','; j++, i++)
{sscanf(&bufferLine[i], "%c",&ch);
if(ch != ',')
tempLine[j] = ch;
lastch = ch;}
for( j = 0,lastch = NULL; lastch != ','; j++, i++)
{sscanf(&bufferLine[i], "%c",&ch);
if(ch != ',')
tempLine[j] = ch;
lastch = ch;}
for( j = 0,lastch = NULL; lastch != ','; j++, i++)
{sscanf(&bufferLine[i], "%c",&ch);
if(ch != ',')
tempLine[j] = ch;
lastch = ch;}
for( j = 0,lastch = NULL; lastch != ','; j++, i++)
{sscanf(&bufferLine[i], "%c",&ch);
if(ch != ',')
tempLine[j] = ch;
lastch = ch;}
}
}
tempLine[j-i] = '\0';//tempLine is set to a NULL or in other words is
clear
strcpy(item.partId, tempLine);
fwrite (&item, sizeof(struct invent),1, outPut);
/*fseek (outPut,0L, SEEK_SET);
fread (&item, sizeof(struct invent,1, inPut);
while(!feof(outPut))
offset = ftell(outPut);
*/
printf("get character\n");
getch;
return 0;
}
My compiler pointed at this: