#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct PROCESS{
int priority;
int lifecycle;
int ttl;
}process1,process2,process3,process4,process5,process6;
main(){
PROCESS *waiting_queue;
waiting_queue = process1; //this is were I get the error.
waiting_queue =(PROCESS *)malloc(6*sizeof(PROCESS));
if(!waiting_queue){printf("no memory for waiting queue "); exit(0);}
getch();
}
I am trying to create a struct array with pointer. I am getting the error. Expected primary expression before ';' token
You should create your struct object from (process1 to process6).
Let me give you an example:
#include <stdio.h>
#include <string.h>
typedef struct student
{
int id;
char name[20];
float percentage;
} status;
int main()
{
status record;
record.id=1;
strcpy(record.name, "Orcun");
record.percentage = 86.5;
printf(" Id is: %d \n", record.id);
printf(" Name is: %s \n", record.name);
printf(" Percentage is: %f \n", record.percentage);
return 0;
}
This is why you are getting your error in your main function. So you should create your struct object like:
process1 processOrcun;
You can also check here : https://www.codingunit.com/c-tutorial-structures-unions-typedef
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments