0
C STRUCTURE / file PROBLEM
Below i have a code that takes students infos a d save it in a file my problem is when it comes to read the file i only see infos of the first student why so ? ps: it's built with French words . plus i copied this code from devc++ that is why it's shown CPP =D https://code.sololearn.com/c3BL7WuysT7R/?ref=app
5 odpowiedzi
+ 1
https://code.sololearn.com/cia4pNkD533z/?ref=app
You need to increment i before you scanf again inside the loop. You also seem to be missing a '&' symbol in your scanf before the nom, as well as missing the prenom in the scanf.
+ 1
Adnane Akkouche you're correct. I don't use scanf ever, so I forget these things 😅
0
Zeke Williams They are strings they don't have to have the " &"
0
Zeke Williams 😅 Okkeey , thank you fir your help !! also is there some advices while coding with files ? like when using fprintf i have to add \n etc... ??
0
You're welcome! When working with files I always pick a format that will be easy to read again. If you have data that varies in length, you should put delimiters in between each piece of data. You don't need the newline, but it will help for human-readability of the file.