What's wrong with this code for NOLOGIC? I am getting WA

I am getting a string. And in array at every index by default 1 is stored. Then at every that index which is equal to its ascii code of the character in string, zero is stored if the character is in the string. At the end the first index of array which does not store 0 is printed out as a character. SO in the answer only one character is printed. There is room for printing tilde (~) too! Please help!

http://www.codechef.com/viewsolution/4371051

gets() function has undefined behaviour which will be difficult for u to determine in case u are using
codeblocks.Furthur ,u will have to clear buffer in case u are using C.

//