The code is working correctly. "char x;" defines x as a single character. Did you mean "string x;"?