If you use a trailing space (a space at the end of the format string), your program appears to hang. Instead of entering a blank line or using space characters, you must enter what the value of str2 will be. The same for str3 and when it asks for str3's value, you would enter a value that won't appear. For example, use "%[^\n] " instead of "%[^\n]"/" %[^\n]". Your newline will be ignored as specified...and eaten by the trailing space in the format string. Since scanf didn't get a '\n' character, it will want more data. str2 will have that value and str3 will have str2's value.