How to scan for ints in a file | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to scan for ints in a file

Ok so I'm making a program that stores the names, ids, and grades of students, and I'm trying to search for students by ids , but I can't use strcmp bec ids are ints and. any help would be appreciated .

9th May 2020, 12:45 AM
PIZZA
PIZZA - avatar
2 Answers
9th May 2020, 2:12 AM
BroFar
BroFar - avatar
0
You do create a struct to hold name, id and grade. Then you create an array of students. For comparison, // pseudo code int id = id_tobe_searched; for (int i=0; i<arr.length; i++) { if (arr[i].id == id) print ( "student found !"); } edit: if you are taking the data from external source like .txt or .json files then u first need to convert them to the form above.
9th May 2020, 1:43 AM
Mustafa K.
Mustafa K. - avatar