|There is a fundamental error in your program which probably explains your result. You have declared an array of char of size 14 and are initializing it with a string containing 14 characters. But a C string, which is what "strlen" is looking at, must end with a null character - this is what determines when the string ends. You have initialized char to '1', char to '1', ... char to '0'. But there is no null character at the end of the string (there are no more elements in the array to hold the null character. So as far as C is concerned, your string goes on with the random values contained in memory after the end of your array. It just so happens that, after another 4 characters, it finds a null. Depending upon your platform, C compiler and, no doubt, other factors, it could have taken any number of characters to find that null. (I tried this with gcc on 64-bit Linux and it actually gave the correct result; obviously the memory value immediately after the array happened to be null.)|
What you need to do if you want a 14 character string is to make the array 15 characters long. This allows for the terminating null character.
In this case the result was merely a puzzle. In practice this sort of error normally leads to program crashes and/or security problems; it is the infamous "buffer overrun" error.