0

How to deal with multiple data stored in dbms?

I have started a mini project, if I use append mode and keep on storing the data of multiple users, then how can I deal with the previous data which I have stored?. Suppose if I store the data of 3 customers in a txt file, now I have to deal with the data of the first customer, then how can I do so?

1st Apr 2020, 5:35 PM
Shubham Prashant
Shubham Prashant - avatar
1 Respuesta
+ 3
Use the fseek() function to position the file pointer at the desired record. You will need the file to be open for read access. You can either close the file after writing in append mode and then reopen it for read mode, or you may combine read and append modes when you open it in the first place. If you combine the two, beware that writing to the file will move the file pointer to the end of the file to perform the write. In append mode you can not update/overwrite the current record. Use write mode if you need to update records, which is done by positioning to the record and overwriting the data with fwrite(). Finding records with fseek() is easiest when your records are all the same length. Just seek from the beginning of the file by recNum*recLen bytes. Then use fread() to retrieve the record.
3rd Apr 2020, 3:29 AM
Brian
Brian - avatar