Exemple #1
0
int main()
{
	printf("Enter No. of Slots: ");
	int slots,i;
	scanf("%d",&slots);
	printf("Enter %d Regno and OwnerName \n",slots);
	ParkingLot pl;
	pl.c.owner_name = (char*)malloc(sizeof(char)*50);	
	//printf("%d\n",TOP);
	
	//Enter_ParkingLot(pl,slots);
	for( i = 0; i < slots ; i++ )
	{
		scanf("%d%s",&pl.c.regno,pl.c.owner_name);
		Enter_ParkingLot(pl,slots);
	}
	printCurrentlyParked();
	sortcars();
	printf("Sorted:\n");
	printCurrentlyParked();
	return 0;
}
Exemple #2
0
int main(){

int size;
printf("enter the size of parking lot \n");
scanf("%d", &size);

parkingLot pl, temp;
parkedCar *pc, *pt;
pc = (parkedCar*)malloc(size * sizeof(parkedCar));
pt = (parkedCar*)malloc(size * sizeof(parkedCar));

pl.first = pc;
temp.first = pt;

int choice = 1;
	printf("size is %d \n", size);
	car list[cap];
	car temp;
	parkedCar pc;
	while(choice)
	{
		printf("want to continue?\n ");
		printf("0 -----> exit\n ");
		printf("1 -----> add a car\n ");
		printf("2 -----> print details of all cars in the parking lot\n");
		scanf("%d", &choice);
		if(choice == 0)
			break;
		else if(choice == 1)
		{		
			printf("enter owner's name\n");
			scanf("%s", &temp.owner);
			printf("enter registration number\n");
			scanf("%s", &temp.regNo);
			strcpy(pc.parkingid, strcat(c.regNo,c.owner));
			pc.car = temp;
			Enter_ParkingLot(pl, pc, size);
		}
		
		else if(choice == 2)
			printCurrentlyParked(pl, temp);
	}

return 0;
}