My code is
//header files
#include <stdio.h>
#include<conio.h>
//declare structure for process
struct process
{
char pr; //process name
int A,ex,end,period;
};
struct process P[10];
int main()
{
int N,i;//no. of process
printf("enter number of task \n");
scanf("%d",&N);
printf(" enter processname executiontime period ");
for(i=0;i<N;i++)
{
printf("\n P[%d] . process name=",i);
scanf("%c", &P[i].pr);
printf("\n P[%d] . execution time =",i);
scanf("%d", &P[i].ex);
printf("\n P[%d] . period=",i);
scanf("%d", &P[i].period);
P[i].A=0;
P[i].end = P[i].A + P[i].ex; //here A=0
}
printf("processname\texecutiontime\tperiod\n");
for(i=0;i<N;i++)
{
printf("%c\t%d\t%d\n", P[i].pr,P[i].ex,P[i].period);
}
getch();
}
The output i am getting is :
enter number of task
3
enter processname executiontime period
P[0] . process name=
P[0] . execution time =1
P[0] . period=2
P[1] . process name=
P[1] . execution time =3
P[1] . period=4
P[2] . process name=
P[2] . execution time =5
P[2] . period=6
processname executiontime period
1 2
3 4
5 6
What's going on — why won't it wait for the process name?