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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:49:16+00:00 2026-06-05T04:49:16+00:00

I really don’t have a clue how to give this question a good title

  • 0

I really don’t have a clue how to give this question a good title – sorry for that.

Just to know what’s the goal of all this: pass a uint8_t variable pointer to bar() which does set it to 1 or 0, that I can check it’s state inside my main. I do need zbar(), it’s a thread and it does actually setting the value to 1 or 0

So I have somewhere:

struct foo_t {
    ...
    uint8_t *state;
};

and in main I go with:

int main(void) {
     uint8_t state = 0;
     bar(&state);

     while(1) {
          if(state)
              //do something here
     }
}

and here we have somewhere else in another sourcefile.

void bar(uint8_t *state) {
    struct foo_t *foo;    //using malloc here - don't worry

    foo->state = state;

    zbar(foo); 

}

void zbar(struct foo_t *arg) {
    if(condition)
       arg->state = 1;
    else
       arg->state = 0;
 }

How to make this working? o0
zBar can actually access the arg struct, that’s not the problem at all.

Please don’t worry why I do it so strange, it’s used within threads etc.

  • 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-05T04:49:17+00:00Added an answer on June 5, 2026 at 4:49 am

    I assume you meant void bar(uint8_t* state)?

    It does not do what I think you intended. Again I assume you want the state variable in main to be changed? If so try

    struct foo_t {
        uint8_t* state; // changed this to a pointer type.
    }
    
    void bar(uint8_t* state) {
        struct foo_t *foo = blah blah;
        foo->state = state;
        zbar(foo);
    }
    
    void zbar(foo_t* arg) {
       if (condition)
           *(arg->state) = 1;
       else
           *(arg->state) = 0;
    }
    

    I tihnk this is what you’re trying to do

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

Sidebar

Related Questions

I really don't know how to title this question, but I need some help
A really boring question, sorry, but I really don't know that yet ;) I've
I have this json object (which i don't really know what is inside) and
I have a homework problem that I really don't know how to start. Here
I have this problem and really don't know how to solve this. I'm having
I have very simple situation and really don't have a clue why this isn't
I really don't know how to express this question. But what I'm trying to
This is one of things that I really don't get. I know that it's
Not really sure how to ask this question because I really don't know what
I really don't know where to begin with this question, but the site I'm

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.