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

  • SEARCH
  • Home
  • 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 8649887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:40:12+00:00 2026-06-12T13:40:12+00:00

I have an array of typedef structure. It is declared as such: vertex vertexArray[numberVertices];

  • 0

I have an array of typedef structure.

It is declared as such:

vertex vertexArray[numberVertices];

I then have this in my main code:

 for(i=0;i<numberVertices;i++)
        {
                if(vertexArray[i].source == 5)
                {
                        source = vertexArray[i].number;
                        walk(vertexArray, vertexArray[i], source, headMaxPairList );
                }
        }

To hopefully perform the walk:

    void walk(vertex *vertexArray, vertex v, int source, maxPairing *head)
{
    int i;
    adjEdge *traverse;
    int moveVertex;
    int sink;




            moveVertex = vertexArray[v.number-1].number;
            if(vertexArray[moveVertex-1].color != 5 && vertexArray[moveVertex-1].sink == 5)
            {
                    sink = vertexArray[moveVertex-1].number;
                    vertexArray[moveVertex-1].color = 5;
                    addMaxPair(head, source, sink);
            }
            else
            {
                    walk(vertexArray, vertexArray[moveVertex-1], source, head);
            }

}

However, I am getting a seg-fault on the function:

in walk (vertexArray=Cannot access memory at address 0x7fffff3fefe8

I believe this has to do with the way I’m passing vertexArray.

It is my understanding that arrays are actually pointers, hence the vertex *vertexArray and then an individual member is just a vertex, not a pointer hence vertex v.

If anyone could help me with getting this passed correctly I’d be appreciative.

Side note, if anyone can tell if my walk looks like it’ll work correctly that’s a plus!

  • 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-12T13:40:14+00:00Added an answer on June 12, 2026 at 1:40 pm

    Arrays are not same as pointers.

    Read the following Links for clarification:

    Q: So what is meant by the “equivalence of pointers and arrays” in C?

    http://c-faq.com/aryptr/aryptrequiv.html

    Q: But I heard that char a[] was identical to char *a.

    http://c-faq.com/aryptr/aryptr2.html

    To avoid Seg-Fault, add the following checks to walk() function:

    void walk(vertex *vertexArray, vertex v, int source, maxPairing *head)
    {
        int i;
        adjEdge *traverse;
        int moveVertex;
        int sink;
    
    
        /* Add this Check to Avoid Seg Fault, you need to make the value of  
          'numberVertices'available to this function as this is your array size */
    
        if ((((v.number-1)<0)||((v.number-1)>numberVertices))
        {
           return;
        }
        /* Check Ends */
    
                moveVertex = vertexArray[v.number-1].number;
    
        /* Another Check */
        if((moveVertex-1<0)||(moveVertex-1>numberVertices))
        {
           return;
        }
        /* Check Ends */
    
                if(vertexArray[moveVertex-1].color != 5 && vertexArray[moveVertex-1].sink == 5)
                {
                    sink = vertexArray[moveVertex-1].number;
                    vertexArray[moveVertex-1].color = 5;
                    addMaxPair(head, source, sink);
                }
    
                else
                {
                        walk(vertexArray, vertexArray[moveVertex-1], source, head);
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, I have this structure and code: typedef struct { long long *number;
I have this C code for a Point structure: typedef struct Point{ int x,
I have the STRUCT1 Structure declared as below typedef struct struct1 { short int
I have a C structure that looks like this typedef struct event_queue{ Event* event;
I have a C structure like this : typedef struct ip_esp_private { /* keep
I have this structure based multimap and a vector for this structure: typedef std::multimap<char,
Would this be the proper way to extend a structure array? typedef struct {
I have this structure typedef struct fpinfo { unsigned long chunk_offset; unsigned long chunk_length;
I have this structure : typedef struct xmlelem{ Char *Element_name; Char *Element_Text; pAttr_Element attr_arr[M];
I have this complicated structure thingie: #include <stdlib.h> typedef struct { int x; int

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.