int FIFO[LIMIT];
int front, rear;
int i;
int choice;
void insert();
void delet();
void display();
int main()
{
printf("FIFO TEST\n\n");
front = rear = -1;
do
{
printf("1. Insert\n2. Delete\n3. Display\n4. Exit\n\n");
xil_printf("Enter your choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
insert();
break;
case 2:
delet();
break;
case 3:
display();
break;
case 4:
exit(0);
break;
default:
printf("Sorry, invalid choice!\n");
break;
}
} while(choice!=4);
return 0;
}
void insert()
{
int element;
if (rear == LIMIT - 1)
xil_printf("FIFO Overflow\n");
else
{
if (front == - 1)
front = 0;
xil_printf("Enter the element to be inserted in the FIFO: ");
scanf("%d", &element);
rear++;
FIFO[rear] = element;
}
}
void delet()
{
if (front == - 1 || front > rear)
{
xil_printf("FIFO Underflow \n");
}
else
{
xil_printf("The deleted element in the FIFO is: %d\n", FIFO[front]);
front++;
}
}
void display()
{
int i;
if (front == - 1)
{
xil_printf("FIFO underflow\n");
}
else
{
xil_printf("The elements of the FIFO are:\n");
for (i = front; i <= rear; i++)
xil_printf("%d\n", FIFO[i]);
}
}
Question
rmccormack1
So I am getting an error saying makefile:38 fifo_test_app.elf Error 1. I do not know why I am getting this error Here is my code:
#include <stdio.h>
#include <stdlib.h>
#define LIMIT 32
int FIFO[LIMIT];
int front, rear;
int i;
int choice;
void insert();
void delet();
void display();
int main()
{
printf("FIFO TEST\n\n");
front = rear = -1;
do
{
printf("1. Insert\n2. Delete\n3. Display\n4. Exit\n\n");
xil_printf("Enter your choice:");
scanf("%d",&choice);
switch(choice)
{
case 1:
insert();
break;
case 2:
delet();
break;
case 3:
display();
break;
case 4:
exit(0);
break;
default:
printf("Sorry, invalid choice!\n");
break;
}
} while(choice!=4);
return 0;
}
void insert()
{
int element;
if (rear == LIMIT - 1)
xil_printf("FIFO Overflow\n");
else
{
if (front == - 1)
front = 0;
xil_printf("Enter the element to be inserted in the FIFO: ");
scanf("%d", &element);
rear++;
FIFO[rear] = element;
}
}
void delet()
{
if (front == - 1 || front > rear)
{
xil_printf("FIFO Underflow \n");
}
else
{
xil_printf("The deleted element in the FIFO is: %d\n", FIFO[front]);
front++;
}
}
void display()
{
int i;
if (front == - 1)
{
xil_printf("FIFO underflow\n");
}
else
{
xil_printf("The elements of the FIFO are:\n");
for (i = front; i <= rear; i++)
xil_printf("%d\n", FIFO[i]);
}
}
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now