The error is just what it says: you are returning the address of a local variable; but once the function has ended (and the address returned) the local variable ceases to exist, which means you are pointing at nothing in particular. Pass in the array to hold the flipped value instead.