Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6202333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:42:55+00:00 2026-05-24T04:42:55+00:00

I was trying to implement a simple queue in C programming. But I encountered

  • 0

I was trying to implement a simple queue in C programming. But I encountered with the following error. Can anyone find me what is wrong in my program

#include<stdio.h>
#include<stdlib.h>
#define QUENE_SIZE 10
struct queue_structure{
  unsigned int queue_front, queue_rear;
  int queue_array[10];
};
void enqueue(struct queue_structure *,int value);
int dequeue(struct queue_structure *);
int queue_full(struct queue_structure *);
int queue_empty(struct queue_structure *);
int main(){
  struct queue_structure *queue_pointer = malloc(sizeof(struct queue_structure));
  int option,number,i,dequeue_number;
  queue_pointer->queue_front = queue_pointer->queue_rear = -1;
  while(1){
    printf("Enter the option:\n");
    scanf("%d",&option);
    switch(option){
      case 1:
        printf("Enter the number to be enqueued:\n");
        scanf("%d",&number);
        if(queue_full(queue_pointer) != 1){
          enqueue(queue_pointer,number);
        }
        else{
          printf("The queue is full");
        }
        break;
      case 2:
        if(queue_empty(queue_pointer) != 1){
          dequeue_number = dequeue(queue_pointer);
          printf("%d has been dequeued",dequeue_number);
        }
        else{
          printf("Your queue is empty\n");
        }
        break;
      case 3:
        for(i = 0; i < 10 ; i++ ){
          printf("%d",queue_pointer->queue_array[i]);
        }
        break;
      case 4:
        exit(0);
        break;
    }
  }  

}
void enqueue(struct queue_structure *qs, int number){   
  if(qs -> queue_front == qs -> queue_rear){
    qs->queue_front = qs->queue_rear = -1;
  }
  else{
    (qs -> queue_rear)++;
    qs->queue_array[qs->queue_rear] = number;    
  }  
}
int dequeue(struct queue_structure *qs){
  int i;
  if(qs->queue_front == qs->queue_rear){
    qs->queue_front = qs->queue_rear = -1; 
  }
  else{
    for(i = qs->queue_front; i < qs->queue_rear ; i++){
      qs->queue_array[i] = qs->queue_array[i + 1];
    }
  }
}
int queue_full(struct queue_structure *qs){
  if((qs->queue_rear == 10) && (qs->queue_front == 0)){
    return 1;
  }
  else{
    return 0;
  }
int queue_empty(struct queue_structure *qs){
  if((qs->queue_rear && qs->queue_front) == -1){
    return 1;
  }
  else{
    return 0;
  }
}

}

I am getting the following error

/tmp/ccLJHnMG.o: In function main':
queue1.c:(.text+0xda): undefined reference to
queue_empty’
collect2: ld returned 1 exit status**

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:42:56+00:00Added an answer on May 24, 2026 at 4:42 am
    int queue_full(struct queue_structure *qs){
      if((qs->queue_rear == 10) && (qs->queue_front == 0)){
        return 1;
      }
      else{
        return 0;
      }
    } <<<<<<<<<<<<<<<<<<<<<<
    int queue_empty(struct queue_structure *qs){
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement a simple priority queue from array of queues. I'm trying
I am trying to implement a simple log using Nlog 1.0, using the following
I'm trying to implement a simple queue that performs one task at a time.
I'm trying to implement a simple queue that performs one task at a time.
I am trying to implement simple program in Java that will be used to
I'm trying to implement a simple function using jqGrid, but it doesn't seem to
This maybe a very noobish question but I am trying to implement a simple
I'm trying to implement a simple horizontal navigation menu that just shows a single
I am trying to implement a simple request to Wikipedia's API using AJAX (XMLHttpRequest).
I am trying to implement a simple authorization strategy for my Wicket application. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.