+ 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 .
2 Réponses
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.