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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:36:22+00:00 2026-06-11T06:36:22+00:00

Here is my code: struct queue { int queue_arr[5]; int rear; int front; };

  • 0

Here is my code:

struct queue {
        int queue_arr[5];
        int rear;
        int front;
};

int main()
{
        struct queue q;
        int choice;

        queue_init(q);
}

queue_init(struct queue *q)
{
        int i = 0;
        q->rear = -1;
        q->front = -1;
        for (; i < MAX; i++) {
                q->queue_arr[i] = 0;
        }
}

It causes segmentation error on execution:

[root@workmachine test_cpp]# ./queue  Segmentation fault (core dumped)

If I remove struct I’ll use int queue_arr[5]; int rear; int front; as global segmentation error disappears. Why? and how to to avoid it whit using of structs?

  • 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-06-11T06:36:23+00:00Added an answer on June 11, 2026 at 6:36 am

    You should pass the address:

    queue_init(&q);
               ^
    

    I’m surprised it compiles as it stands.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the code for templates specilization: template <int i> struct userInput{}; template <>
Here is the code: .... typedef struct { int buf[10]; long head, tail; int
I need to read certain statistics from iw_statistics structure, here's the code: struct net_device
So here's a snippet of my code: struct dv_nexthop_cost_pair { unsigned short nexthop; unsigned
where is the mistake? My code here: typedef struct _box { char *dados; struct
here is my code for xor linked list implementation #include<iostream> using namespace std; struct
Here is some simple code: DIR* pd = opendir(xxxx); struct dirent *cur; while (cur
The following code doesn't build. struct some_struct { some_struct() { ... do something here
Here is some code: struct K : CGAL::Exact_predicates_inexact_constructions_kernel {}; typedef CGAL::Triangulation_vertex_base_2<K> Vb; typedef CGAL::Constrained_triangulation_face_base_2<K>
I have the following code struct Node { int accnumber; float balance; Node *next;

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.