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 6810741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:14:32+00:00 2026-05-26T20:14:32+00:00

here is queue implementation which gives me very unclear error #include<iostream> #include bool.h #include

  • 0

here is queue implementation which gives me very unclear error

#include<iostream>
#include "bool.h"
#include "item.h"
#include "queue.h"

using namespace std;

void init_queue(queue *q){
    q->first=0;
    q->last=queuesize-1;
    q->count=0;

}
       void enqueue (queue *q,item_type x){
           if(q->count>=queuesize)
               cout<<" queue everflow occurs during enqueue "<<endl;
           else
           {
               q->last=(q->last+1)%queuesize;
               q->m[q->last]=x;
               q->count=q->count+1;

           }




       }

             int dequeue (queue *q)
             {
                 item_type x;
                 if(q->count<=0) cout<<"empthy queue "<<endl;
                 else
                 {
                     x=q->m[q->first];
                     q->first=(q->first+1)%queuesize;
                     q->count=q->count-1;
                 }
                 return (x);




                 }



             item_type headq(queue *q)
             {
                 return(q->m[q->first]);
             }
             int empthy(queue *q){


                 if (q->count<=0) return (TRUE);
                 else return (FALSE);
             }

 void print_queue(queue *q){
     int i;
     i=q->first;
     while(i!=q->last)
     {
         cout<<q->m[i];
         i=(i+1)%queuesize;
     }
     cout<<q->m[i]<<"  ";

 }
 int main(){
     queue *q;
     init_queue(q);
 int a;
 while(cin>>a){
     enqueue(q,a);




 }
 print_queue(q);


    return 0;
}

see also please queue header file

#define  queuesize 1000
#include "item.h"

typedef struct
{
int  m[queuesize+1];
  int first;
  int last;
  int count;
  }queue;

error is that (actualy) it is not error just warning when i compile,but when i run it says local variable q uninitialized,so which variable q?it is name of structure,so when i run init_queue method it should initialize yes?

  • 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-26T20:14:33+00:00Added an answer on May 26, 2026 at 8:14 pm
     queue *q;      
    init_queue(q); 
    

    You are not allocating the memory for q.

    queue *q = new queue;

    You can allocate the queue on stack as well: ( recommended !)

    queue q;
       init_queue(&q); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is the implementation of my queue, which has functionality of enqueueing and dequeing
Here is an implementation of a thread safe queue. The push and pop won't
I have an application which uses an im-memory implementation of Queue. I need to
I'm trying to implement a Polymorphic Queue. Here is my trial: QQueue <Request *>
I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here's the
Here is my code, which takes two version identifiers in the form 1, 5,
I wrote an implementation for a priority queue I needed, and now I would
I have a queue in which I can enqueue different threads, so I can
I am writing a custom queue implementing the queue interface. This implementation is thread
I have a priority queue implementation in C# that I want to add a

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.