#include<stdio.h>
#include<stdlib.h>
struct sales
{ int week;
char name[20];
int units;
int price;
};
int main ()
{
char data1[300];
int itemAmount = 0;
char itemNumber[10];
int timeToFinish = 0;
int elapsedMinutes = 0;
int iLoop = 0;
int readCounter = 0;
int finishTime[20];//holds the finish items
int counter = 0;
printf ("Enter a filename to load: ");
scanf ("%s" , &data1[0]);
FILE *ptrFileIn;
ptrFileIn= fopen("data1","r");
if (ptrFileIn != NULL)
{
for (iLoop=0; iLoop<14; iLoop++)
{
finishTime[iLoop] = 0;
}
while (!feof(ptrFileIn))
{
fscanf(ptrFileIn, "%s %d %d", &itemNumber, &timeToFinish,
&elapsedMinutes);
finishTime[counter] = timeToFinish;
//finishTime[counter] = elapsedMinutes;
counter++;
}
printf ("\nFile successfully loaded!\n");
fclose(ptrFileIn);
for (readCounter = 0; readCounter < 15; readCounter++)
{
if (finishTime[readCounter] != 0)
{
printf("item%d %d %d\n", readCounter, finishTime
[readCounter]);
}
}
}
else {
printf("Error: The file you specified could not be found!");
}
system ("PAUSE");
return 0;
}
cessna172 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
invisal 381 Search and Destroy
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.