Ok, I just read through that and used the quiz too, will bookmark for more use.
One last question though..
Would you personally say that how I initially grab the file would be the best way for this project? I grab the file, and split it into it's three different parts while reading it and then create a file for each of these names and add there items and amount in there.
I'm leaving out the part where I need to keep track of how many names right now. If this part is right/a good way to go, then I will be able to work on the structure next.
code is right here and works fine as far as creating the files it needs to create.
Code:
int main(void){
char buffer[50];
char name[15];
char item[99];
int amount;
FILE *fp;
FILE *fp2;
int i;
if ( (fp = fopen("names.csv", "r" )) == NULL )
{
printf("Couldn't open file\n");
exit(1);
}
while(fgets(buffer, sizeof(buffer), fp))
{
sscanf(buffer,"%[^,] ,%[^,], %d", &name, &item, &amount);
strcat (name, ".txt");
//create file for names
if( (fp2 = fopen(name, "a")) == NULL )
{
printf("unable to open %s\n", name);
exit( 1 );
}
fprintf(fp2, "%s,%d\n", &item, amount);
fclose(fp2);
}
fclose(fp);
}