I always get a garbage value like this \'Íýýýý««««««««îþîþ\' at the end when i output my array. What am I doing wrong?
void func() { const int size = 100
Because you don't null terminate your buffer, std::cout.operator<<(char*) will try to find \0 as its terminating character.
std::cout.operator<<(char*)
\0
As pointed out in comments, feel free to append that \0 to the end of your buffer :).