arduino uint16_t assignment error

Hi all.

I do not know if this is my bad code or an arduino bug. I tried to create a simple library. But when I came to something like assigning a pointer variable to a value larger than 255 (0xFF) it makes the program crashed and restart. You may have a look at the source code I attached and try it yourself. Is this only me? Any hints are appreciated.

I am using Arduino IDE version 1.6.7 64 bit. I have also tried it on version 1.6.0 and 1.0.5 64 bit but got the same result.

testword.ino (374 Bytes)

libword.h (185 Bytes)

libword.c (80 Bytes)

You are using an uninitialized variable...

  uint16_t *num;
  uint8_t x = retword(num);

num needs to point to storage before the call to retword.

Thank you for the fast reply. But when I put the retword implementation in sketch, it works normally. Did the sketch do the initialization for me?

No. The code will never "work normally". What happened was you got very lucky.