because of the fact that you're reading a string into a char location, it's likely that the terminating \0 is wiping out the contents of x. This is a pretty clear case of undefined behavior.