help! I'm trying out c programming and I'm stuck in this certain part.
I have an array of structures (max of 10) which i need to store in a non-text file.
You see, my program goes that there is a registration part. So every time someone signs up, i have to save it in the file using one of the array of structure.
So how do I keep track of how many I've already stored in the file, and how do I know at what position do I save it? I tried it out using loops but it doesn't seem to work. Am I doing it right like this: ??
if ((pUser = fopen("buyerstemp.dat", "w+b")) != NULL)
{
while(!feof(pUser))
{
fread (&aUser[i], sizeof(arrUser), 1, pUser);
if (!feof(pUser))
i++;
}
//**the rest here is the part wherein I'm asking the necessary info from the user **//
then at the end part I have the fwrite thing.
Am I doing this right? Help!