The main problem you're having is that strlen calculates the length of the string data already in the string you give it.