Simple Question: Please read

I have the following code snippet from my program that i am working on

bit running = 0;
float var1, average_value;


    void is_something_running(void) {
    if (fabs(var1 - average_value) <= 0.001){
    return *(&running) = 0;   }
    else
    return *(&running) = 1;
    }

var1 and average value get their value from somewhere else.

My question is, can I change a value by referencing to it with a pointer to its address <return *(&running)>. Is this good programming?

Thanks,
MT

Recommended Answers

All 2 Replies

Not sure what bit running = 0; is and why you need to take the address and then dereference it...Won't it make more sense to just assign 0 or 1 to running?

This makes more sense

bit running = 0;
float var1, average_value;


    void is_something_running(void) {
      running = (fabs(var1 - average_value) <= 0.001) ? 0 : 1;
      return running;
  }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.