SOLVED: Can anyone explain this to me please.

Here is the Code.

struct PortNode {     
    byte Number;
};

void setup() {
    Serial.begin(9600);
  
    // Setup a new port
    PortNode *Port;
    Port->Number = 5; 
    Serial.println(Port->Number);
    Serial.println(Port->Number);
    Port->Number = 5; 
    Serial.println(Port->Number);
    Serial.println(Port->Number);
}
void loop() {
}

And the output on the serial monitior is:
5
255
5
255

This has me confused. Any ideas why this is behaving this way.

Board: UNO
IDE: 1.0.5-r2

Thanks

You are using a pointer to nowhere:

PortNode *Port;

Try:

struct PortNode {     
    byte Number;
};

void setup() {
    Serial.begin(9600);
  
    // Setup a new port
    PortNode p;
    PortNode *Port = &p;
    Port->Number = 5; 
    Serial.println(Port->Number);
    Serial.println(Port->Number);
    Port->Number = 5; 
    Serial.println(Port->Number);
    Serial.println(Port->Number);
}
void loop() {
}

Crap I didnt create the node did I.

PortNode *Port = new PortNode;

I looked at that for ages.

Thanks sorry.