The code i made is used to read a .txt file and retrieve the largest integer. But im having trouble on how i can make the code read student name and id for student with high avg marks.
in the txt file there will
Roll no. Name mark
example:
190 james 100
i would really appreaciate if you guys could help me out. thank you.
Code:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include <stdio.h>
int main()
{
FILE *sensor;
int num,max, sum, count, first;
sensor = fopen("C:\\Users\\SMLUser\\Desktop\\test.txt", "r");
if (sensor != NULL)
{
for (sum = count = first = 0;
fscanf(sensor, "%d", &num) == 1; sum += num, ++count)
if (!first)
{
max = num; first = 1;
}
else if (num > max) max = num;
fclose(sensor);
printf("max = %d \n",max);
}
else
{
printf("Unable to read file 'C:\\Users\\SMLUser\\Desktop\\test.txt" );
}
getch();
}