Hello I kinda need guidance on why my code is not working, ive spent a couple of hours tracing for errors but nothing seems out of the ordinary. The topic is all about reading a text file and extracting those values to perform round robin scheduling algorithm.
#include <stdlib.h>
struct Process {
int id;
int arrTime;
int burTime;
int waitTime;
int tat;
};
int main()
{
struct Process p[64];
int i, num_processes = 0, time_slice = 0, count = 0, wt = 0, tat = 0, sum = 0, j, y;
float avg_wt, avg_tat;
int temp[10];
FILE *input_file = fopen("data.txt", "r");
if (input_file == NULL)
{
printf("Error opening file\n");
return 1;
}
fscanf(input_file, "%d", &num_processes);
y = num_processes;
fscanf(input_file, "%d", &time_slice);
printf("%d\n%d\n", num_processes, time_slice);
for(i= 0; i < num_processes; i++)
{
fscanf(input_file, "%d %d %d", &p[i].id, &p[i].arrTime, &p[i].burTime);
temp[i] = p[i].burTime;
printf("%d %d %d\n", p[i].id, p[i].arrTime, p[i].burTime);
}