Change "p++" for "++p" Your code means "Write p data and after increment p". This change that I told you means "increment p and after write p...
Separate names with a comma.