Instead of sizeof() for finding the length of strings or character arrays, just use strlen(string_name) with the header file #include <cstring> it's easier.