i'm getting this error when i run the following code
robin.c: In function `runProcess':
robin.c:72: request for member `name' in something not a structure or union
robin.c:73: request for member `executionTime' in something not a structure or union
#include <stdio.h>
#include <stdlib.h>
#define NAME 10
typedef struct
{
char name[NAME];
int timeForExecution;
int timeLeft;
int waitTime;
int turnAroundTime;
} Process;
int main(int argc, char* argv[])
{
Process* p;
char name[NAME];
int numberOfProcesses = 0;
int timeSlice = 0;
int i = 0;
int execTime;
printf("Please enter the number of processes\n"
;
scanf("%d", &numberOfProcesses);
printf("Please enter the timeslice\n"
;
scanf("%d",&timeSlice);
//allocate memory
p = malloc(numberOfProcesses*sizeof(Process));
for(i = 0; i < numberOfProcesses; i++)
{
printf("Please enter a name for this process\n"
;
scanf("%s", name);
strcpy(p.name,name);
printf("Please enter the ammont of time this process requires to complete execution\n"
;
scanf("%d", &execTime);
p.timeForExecution = execTime;
}
roundRobin(p, numberOfProcesses, timeSlice);
}
roundRobin(Process* p, int numberOfProcesses, int timeSlice)
{
int totalExecutionTime = 0;
int i = 0;
for(i = 0; i < numberOfProcesses; i++)
{
totalExecutionTime = totalExecutionTime + p.timeForExecution;
}
while(totalExecutionTime > 0)
{
for(i = 0; i < numberOfProcesses; i++)
{
runProcess(&p, &totalExecutionTime);
}
}
}
runProcess(Process* p, int* totalTime)
{
printf("Name is %s", p.name);
printf("exec time is %d", p.executionTime);
}
robin.c: In function `runProcess':
robin.c:72: request for member `name' in something not a structure or union
robin.c:73: request for member `executionTime' in something not a structure or union
#include <stdio.h>
#include <stdlib.h>
#define NAME 10
typedef struct
{
char name[NAME];
int timeForExecution;
int timeLeft;
int waitTime;
int turnAroundTime;
} Process;
int main(int argc, char* argv[])
{
Process* p;
char name[NAME];
int numberOfProcesses = 0;
int timeSlice = 0;
int i = 0;
int execTime;
printf("Please enter the number of processes\n"
scanf("%d", &numberOfProcesses);
printf("Please enter the timeslice\n"
scanf("%d",&timeSlice);
//allocate memory
p = malloc(numberOfProcesses*sizeof(Process));
for(i = 0; i < numberOfProcesses; i++)
{
printf("Please enter a name for this process\n"
scanf("%s", name);
strcpy(p.name,name);
printf("Please enter the ammont of time this process requires to complete execution\n"
scanf("%d", &execTime);
p.timeForExecution = execTime;
}
roundRobin(p, numberOfProcesses, timeSlice);
}
roundRobin(Process* p, int numberOfProcesses, int timeSlice)
{
int totalExecutionTime = 0;
int i = 0;
for(i = 0; i < numberOfProcesses; i++)
{
totalExecutionTime = totalExecutionTime + p.timeForExecution;
}
while(totalExecutionTime > 0)
{
for(i = 0; i < numberOfProcesses; i++)
{
runProcess(&p, &totalExecutionTime);
}
}
}
runProcess(Process* p, int* totalTime)
{
printf("Name is %s", p.name);
printf("exec time is %d", p.executionTime);
}