Searching for char in text file
I have variable char that holds number wich presents id of exam. Now i need to open my text file and search for that number and if it is found programm needs to get name of that exam, and maximum number of points.
Text looks something like this:
5 1 Lab 01
17 2 Lecture(31.10.)
...
where 5 is id exam, 1 is max num of points and Lab 01 is name of exam.
So far i got this:
Code:
char *nazivIspita;
char tmp;
int line_num=1;
FILE *fin=fopen("Ispiti.txt", "r");
while(fscanf(fin, "%d", &tmp)) {
if(tmp==s.sifraIsp) {
printf("A match found\n");
}
}
fclose(fin);