Basically, I created a variable "global" that would loop through the contents of acLineBuffer.
BTW: you should NOT increment the NAME of your allocated buffer. Instead, you would assign a pointer to it (even though it is itself a pointer), and increment that. Anyway, you would be using different copy syntax for that...but FYI...
Code:
void ReadFile(struct SListHeader *ListInfo, FILE *pFLocation)
{
int i, global = 0;
char *acLineBuffer;
char acStateBuff[4], acCityBuff[41], acLatBuff[8], acLongBuff[8], acPopBuff[10], acZipBuff[8];
acLineBuffer = (char*)malloc(100 * sizeof(char));
if (acLineBuffer == NULL)
{
printf("\n\nOut of Memory!!!\n\n");
/* Insert Memory Error Check Here */
}
while ( fgets(acLineBuffer, 100, pFLocation) && global < 100)
{
for ( i=0; acLineBuffer[global] != ','; i++ )
{
acCityBuff[i] = acLineBuffer[global];
global++;
}
acCityBuff[i] = '\0';
//acLineBuffer++;
printf("\n%s read from file.... ", acCityBuff);
printf("\n%s", acLineBuffer);
for ( i=0; acLineBuffer[global] != ','; i++ )
{
acStateBuff[i] = acLineBuffer[global];
global++;
}
acStateBuff[i] = '\0';
//acLineBuffer++;
printf("\n%s - ", acStateBuff);
printf("\n%s", acLineBuffer);
for ( i=0; acLineBuffer[global] != ','; i++ )
{
acZipBuff[i] = acLineBuffer[global];
global++;
}
acZipBuff[i] = '\0';
//acLineBuffer++;
printf("\n%s - ", acZipBuff);
printf("\n%s", acLineBuffer);
for ( i=0; acLineBuffer[global] != ','; i++ )
{
acLatBuff[i] = acLineBuffer[global];
global++;
}
acLatBuff[i] = '\0';
//acLineBuffer++;
printf("\n%s - ", acLatBuff);
printf("\n%s", acLineBuffer);
for ( i=0; acLineBuffer[global] != ','; i++ )
{
acLongBuff[i] = acLineBuffer[global];
global++;
}
acLongBuff[i] = '\0';
//acLineBuffer++;
printf("\n%s - ", acLongBuff);
printf("\n%s", acLineBuffer);
for ( i=0; acLineBuffer[global] != '\n'; i++ )
{
acPopBuff[i] = acLineBuffer[global];
global++;
}
acPopBuff[i] = '\0';
printf("\n%s - ", acPopBuff);
printf("\n%s", acLineBuffer);
printf("\nReady to insert node.....");
}
return;
}