can anyone help me out with this . ? | Sololearn: Learn to code for FREE!

+1

can anyone help me out with this . ?

https://stackoverflow.com/questions/53672701/saving-data-in-files-in-c

12/11/2018 4:49:11 AM

Muneer

5 Answers

New Answer

+5

For your second problem: When I close the program and logged in again the information of user reservation deletes. I want to save the user's reservation information too. In registration(): log = fopen("login.txt", "ab"); // must be opened as binary so I added 'b' there ~~~~~~~ In login(): struct login l[100]; // should be a buffer big enough to hold maximum registered users log = fopen("login.txt", "rb"); // binary reading ... for (int i = 0; i < 100; ++i) { fread(&l[i], sizeof(struct login), 1, log); if (strcmp(username, l[i].username) == 0 && strcmp(password, l[i].password) == 0) { system("CLS"); printf("\nYou are successfully logged in !!\n"); fclose(log); menu(); } } system("CLS"); fclose(log); login(); ~~~~~~ Note: By doing the above fixes I can't see any issue with your first problem. Now, you can insert more info to the end of the file. If there's something missing or wrong tell me.

+1

have mentioned someone who can help with the code.... have tried debugging... but it seems am having problem because am checking it out on my phone.....

0

John Wells should be able to help.... i try finding the bug, now am getting headache... i could also learn from this

0

what should i do ? i want to make it work but i dont know how

0

thankyou i am waiting for someone to answer 😭😭