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

2nd Jul 2019, 2:06 AM
Dynno
Dynno - avatar
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.
2nd Jul 2019, 4:33 AM
Zeke Williams
Zeke Williams - avatar
+ 1
Adnane Akkouche you're correct. I don't use scanf ever, so I forget these things 😅
2nd Jul 2019, 4:46 AM
Zeke Williams
Zeke Williams - avatar
0
Zeke Williams They are strings they don't have to have the " &"
2nd Jul 2019, 4:44 AM
Dynno
Dynno - avatar
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... ??
2nd Jul 2019, 4:49 AM
Dynno
Dynno - avatar
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.
2nd Jul 2019, 4:53 AM
Zeke Williams
Zeke Williams - avatar