Can you please check my code

https://ide.codingblocks.com/s/267135. Is my approach right?

you simply need to compare i with i-1 and if it similiar print * then ith character other wise just the ith character
Code