reading the next line in a text file
Hello,
I'm having trouble getting my file pointer to increment to the next line accurately.It reads the first line just fine,but when it loops thru the second time it reads the text from different areas.I feel like i'm close but,I don't really know.If someone could point me in the right direction.I know my code looks horrible and I really need to clean it up.I apologize.
Scott
int main()
{
FILE *inv;
char search_key[6];
int recordcount = 0;
int fieldcount = 0;
char between=TRUE;
int chr;
int a;
char record[85];
char item_num[7];
char category[5];
char ean[13];
char codabar[6];
char vendor_num[4];
char ven_part_num[11];
char title[40];
banner();
printf("* *\n");
printf("* Lets view records by item# *\n");
printf("****************************************** *************\n");
printf(" Enter an Item# : ");scanf("%s", &search_key);
do
{
if ( (inv = fopen("inventory.txt","rt")) == NULL )
fprintf(stderr,"Could not open file inventory.txt\n");
}
while (inv == NULL);
do
{
fgets(item_num,7,inv);
fgets(category,4,inv);
fgets(ean,14,inv);
fgets(codabar,9,inv);
fgets(vendor_num,4,inv);
fgets(ven_part_num,12,inv);
fgets(title,40,inv);
}
while(search_key != item_num);