The best solution is to not use String for mypass. Instead use a null terminated char array (otherwise known as a string). I know it's confusing that String and string have such similar names but it's an important difference to understand. String seems to make things easier at first glance but in the end it's really not so hard to work with strings: