If you must check the length of some string use strlen()
If you want something to be copied to something else, just use copy, don't freaking worry about lenghts because copy requires a length parameter of the string you're writing to so basically, it's failproof.