Looks like undefined behavior to me.
You are not allocating (dynamically) the memory needed to rotor
anywhere. Your createRotor()
function just stores data in some random junk address (that is the value of r
), and you try to access it. You never initialize r
to an address allocated for your program.