Reading a specific line from a file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Reading a specific line from a file

Okay, I would like to know how read a specific line in a file, this is how the data is stored in the file Line 1: John Doe JD0123 Computer Science Monday 8:30-9:30 Line 2: Jane Doe JD4567 English A Tuesday 11:30-12:30 The user should be able to enter the ID(2 letters and 4 numbers) find the line that has the matching ID and print everything on that line any help would be appreciated Thank you.

20th Mar 2020, 7:47 PM
Jergan Hector
Jergan Hector - avatar
2 Answers
0
One way would be to read lines from file with fgets() and compare each line to JDXXXX with strstr(). You have any code done yet?
20th Mar 2020, 7:54 PM
Daniel
Daniel - avatar
0
Here is the code, the trouble is in the view_schedule function https://code.sololearn.com/c7085KWXCOiI
21st Mar 2020, 1:51 AM
Jergan Hector
Jergan Hector - avatar