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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:05:37+00:00 2026-06-12T14:05:37+00:00

Possible Duplicate: C: change pointer passed by value I have a function which receives

  • 0

Possible Duplicate:
C: change pointer passed by value

I have a function which receives both the array, and a specific instance of the array. I try to change the specific instance of the array by accessing one of its members “color”, but it does not actually change it, as can be seen by debugging (checking the value of color after function runs in the main program).

I am hoping someone can help me to access this member and change it. Essentially I need the instance of the array I’m specifying to be passed by reference if nothing else, but I’m hoping there is an easier way to accomplish what I’m trying to do.

Here’s the structures:

typedef struct adjEdge{
        int vertex;
        struct adjEdge *next;
} adjEdge;


typedef struct vertex{
        int sink;
        int source;
        int color;                                                              //0 will be white, 1 will be grey, 5 will be black
        int number;
        adjEdge *nextVertex;
} vertex;

And here is the function:

 void walk(vertex *vertexArray, vertex *v, int source, maxPairing *head)
{
        int i;
        adjEdge *traverse;
        int moveVertex;
        int sink;
        int correctedNumber = v->number;
        traverse = vertexArray[v->number-1].nextVertex;
        if(v->color != 5 && v->sink == 5)
        {
                sink = v->number;
                v->color = 5;
                addMaxPair(head, source, sink);
        }
        else
        {
                walk(vertexArray, vertexArray[traverse->vertex-1], source, head);
        }



}

In particular, v.color needs to be changed to a 5, that way later after recursion the if condition blocks it.

  • 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-12T14:05:38+00:00Added an answer on June 12, 2026 at 2:05 pm

    You are taking the argument by copy so whatever changed inside the function will not be reflected outside. You need to accept the v as vertex*.

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

Sidebar

Related Questions

Possible Duplicate: std::vector<std::string> to char* array I have to call a c function that
Possible Duplicate: Why does the background of TextView change it's size? I have a
Possible Duplicate: Change single variable value in querystring I'm retrieving the current URL: http://example.com/?s=original&fq=category
Possible Duplicate: How to change the href for a hyperlink using jQuery I have
Possible Duplicate: Unable to change DataRow value I bound a datatable to a datagrid.
Possible Duplicate: How to change the href for a hyperlink using jQuery I have
Possible Duplicate: Change language programatically in Android I am creating Application which is a
Possible Duplicate: Can I change the FormsAuthentication cookie name? I have multiple MVC3 sites
Possible Duplicate: How to change the value of ${user} variable used in Eclipse templates
Possible Duplicate: Change the time interval of a Timer So I have a timer:

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.