# defining struct as global variable

**URL:** <https://forums.digi.com/t/defining-struct-as-global-variable/10356>\
**Category:** Rabbit\
**Created:** [July 24, 2009, 11:36am UTC](https://forums.digi.com/t/defining-struct-as-global-variable/10356 "2009-07-24T11:36:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NurulHariLesmono](https://avatars.discourse-cdn.com/v4/letter/n/c4cdca/32.png) [@NurulHariLesmono](https://forums.digi.com/u/NurulHariLesmono)\
**Post date:** [July 24, 2009, 11:36am UTC](https://forums.digi.com/t/defining-struct-as-global-variable/10356/1 "2009-07-24T11:36:59Z")

</div>

Dear friends,

I am new with the dynamic c… this is my code…  
//---------------------------------------------------------------------//  
typedef struct THERMOSTATS\_INFO {  
WORD BlockNumber;  
BYTE Branch;  
BYTE Address;  
BYTE Setpoint\_Celcius;  
BYTE Setpoint\_Fahrenheit;  
BYTE FanSpeedAndModes;  
BYTE Callibration;  
BYTE KeyCard;  
BYTE Function;  
BYTE Minute;  
BYTE Hour;  
BYTE CRC;  
}ETOP\_Thermostats;

static ETOP\_Thermostats TemporaryResult;

void setData(void);

main(){

```
setData();

```

}

void setData(){  
/\* this line –\> \*/ TemporaryResult-\>BlockNumber = 0;  
}  
//---------------------------------------------------------------------//

when i compile it is no error if i am remove any setData relation. but if i pres F9 or run it say runtimeerror…

is it wrong?

what i supposed to do?

Best Regards,  
Hari

---

<div class="post-metadata">

**Author:** ![sgt](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@sgt](https://forums.digi.com/u/sgt)\
**Post date:** [July 24, 2009, 4:14pm UTC](https://forums.digi.com/t/defining-struct-as-global-variable/10356/2 "2009-07-24T16:14:28Z")

</div>

TemporaryResult is a structure, not a pointer. Try:

TemporaryResult.BlockNumber = 0;

Seems like the compiler should have complained about this…

---

<div class="post-metadata">

**Author:** ![NurulHariLesmono](https://avatars.discourse-cdn.com/v4/letter/n/c4cdca/32.png) [@NurulHariLesmono](https://forums.digi.com/u/NurulHariLesmono)\
**Post date:** [July 25, 2009, 2:34am UTC](https://forums.digi.com/t/defining-struct-as-global-variable/10356/3 "2009-07-25T02:34:07Z")

</div>

it’s work!!

thank you sgt 😃
