When you use char*, you need to allocate one extra char and set that to '\0'.