I think that the main problem on my code is that iam trying to pass a struct through another struct .
Is there a problem if i use "->" instead of (*). ?
Because it keeps showing me an error that say's : invalid type of argument '->'
Iam trying about 8 hours and iam really exhausted. I think the mistake is obvious but for the moment my mind is off... :-/
//Include
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
//Include-----------------
//Records
typedef enum
{
FALSE,TRUE
}boolean;
typedef struct
{
char name[25];
}app;
typedef struct
{
int Front;
int Rear;
app applist[2];
}clinic;
typedef struct
{
int Front;
int Rear;
char name[25];
int choice;
char phone[10];
}wait;
//Records ------------------------------------------
//functions
void NewAppointment(int y,clinic *clinic,wait *wait);
int RandomInteger(void);
void CreateQ(clinic *clinic,int i);
void CreateQw(wait *wait);
boolean EmptyQ(clinic clinic,int y);
boolean EmptyQw(wait wait);
boolean FullQ(clinic clinic,int y);
boolean FullQw(wait wait);
void AddQ(clinic *clinic, int y,wait *wait);
void ShowWaitingQ(wait *wait);
void ShowQ(clinic *clinic);
//functions ----------------------------------------------------
//=====================================MAIN===============================
main()
{
char ep;
clinic clinic[6];
wait wait[20];
int i,y;
// Äçìéïõñãßá ôùí 6 ïõñþí ! (5 ïõñÝò ãéá ñáíôåâïý êáé ìßá waiting list)
for(i=1;i<6;i++)
CreateQ(&clinic,i);
CreateQw(&wait);
//ÔÝëïò ôçò Äçìéïõñãßáò ôùí 6 ïõñþí!
//ÅðáíáëçðôéêÞ äéáäéêáóßá ðïõ êáëåß ôéò óõíáñôÞóåéò
while(TRUE)
{
y=RandomInteger();
NewAppointment(y,&clinic,&wait);
printf("Continue? Y/N ( Y=Yes , N=No )\n");
scanf("%c",ep);
if((ep=='n')||(ep=='N'))break;
}
//ÅðáíáëçðôéêÞ äéáäéêáóßá ðïõ êáëåß ôéò óõíáñôÞóåéò-------------------------
//Ôåëåõôáßåò Åìöáíßóåéò <><><><><><><><><><><<><>>
ShowQ(&clinic);
ShowWaitingQ(&wait);
system("pause");
}
//=================================MAIN=====================================
//ShowWaitingQ
void ShowWaitingQ(wait *wait)
{
int Front;
printf("Waiting List:\n");
while(wait->Front!=wait->Rear)
{
printf("%s , %d , %s",wait[Front]->name,wait[Front]->choice,wait[Front]->phone);
printf("\n");
wait->Front = wait->Front +1;
}
}
//ShowWaitingQ-----------------------------------------------
void ShowQ(clinic *clinic)
{
int i;
for(i=1;i<6;i++)
{
printf("Appointments of clinic %d : \n",i);
while(clinic[i]->Front!=clinic[i]->Rear)
{
printf("%s",clinic[i]->applist[clinic[i]->Front]->name);
printf("\n");
clinic[i]->Front=clinic[i]->Front +1;
}
}
}
//NewAppointment
NewAppointment(int y,clinic *clinic,wait *wait)
{
AddQ(&clinic,y,&wait);
}
//NewAppointment -------------------------------
//Random
int RandomInteger(void)
{
int n;
n=rand()%5;
n++;
return(n);
}
//Random----------------------------------
// Ïé Äéáäéêáóßåò Create
void CreateQ(clinic *clinic,int i)
{
clinic[i]->Front = 0;
clinic[i]->Rear = 0;
}
void CreateQw(wait *wait)
{
wait->Front=0;
wait->Rear=0;
}
// Ïé Äéáäéêáóßåò Create--------------------------
//Ïé Äéáäéêáóßåò Empty
boolean EmptyQ(clinic clinic,int y)
{
return (clinic[y].Front == clinic[y].Rear);
}
boolean EmptyQw(wait wait)
{
return(wait.Front == wait.Rear);
}
//Ïé Äéáäéêáóßåò Empty------------------------------
//Ïé Äéáäéêáóßåò Full
boolean FullQ(clinic clinic,int y)
{
return ((clinic[y].Front) == ((clinic[y].Rear +1) % 2));
}
boolean FullQw(wait wait)
{
return((wait.Front) == ((wait.Rear +1) % 20));
}
//Ïé Äéáäéêáóßåò Full--------------------------------
// Äéáäéêáóßá Add
void AddQ(clinic *clinic, int y,wait *wait)
{
int NewRear;
int NewRear1;
int Rear;
char onoma[25];
char number[10];
printf("\n Give your name: ");
if(!FullQ(clinic,y))
{
scanf("%s",onoma);
printf("\nSuccesful appointment for clinic %d ",y);
strcpy(clinic[y]->applist[clinic[y]->Rear]->name,onoma);
NewRear = (clinic[y]->Rear + 1) % 2;
clinic[y]->Rear = NewRear;
}
else if(!FullQw(wait))
{
scanf("%s",onoma);
printf("You are in a Waiting list : ");
strcpy(wait[Rear]->name,onoma);
wait[Rear]->choice=y;
printf("\n Give Your Phone Numer : ");
scanf("%s",number);
strcpy(wait[Rear]->phone,number);
NewRear1=(wait->Rear +1) % 20;
wait->Rear=NewRear1;
}
else
printf("Waiting List is FULL ");
}
// Äéáäéêáóßá Add---------------------------------------------------------------