int main()
{
int* ptr;
int numofstu;
printf("Please enter the number of students: \n");
scanf("%d", &numofstu);
ptr = (int*) malloc(numofstu * sizeof(int));
FILE* fptr;
if ((fptr = fopen("C:\\Users\\umut\\Desktop\\students.txt", "r")) == NULL)
{
printf("Error! opening file");
}
else
{
int highest=0;
for (int i = 0; i < numofstu; i++)
{
fscanf(fptr, "%d\n", &ptr[i]);
if (ptr[i] >highest )
ptr[i] = highest;
}
printf("%d", highest);
}
}
Hello Guys! This is my second semester in C language but i'm still a amateur.
What is the problem of this code chunk. I am posting a new question because i coulnt found any similar resource to solve it?
Thanks in advance :)
Edit: There are 9 integers in students.txt and their order is like int newline int
Edit2: Result is 0 all the time.