Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you use <code>scanf()</code> to read the strings, your format string (<code>%[^\n]</code>) tells the function to read every character that is not <code>'\n'</code>. That leaves the <code>'\n'</code> character in the input buffer. So when you try to read <code>str2</code> and <code>str3</code>, <code>scanf()</code> finds the first thing in the buffer is <code>'\n'</code> each time and, because of the format string, doesn't remove it from the input buffer. What you need is a <code>getchar()</code> between the times that you read from the input buffer (often placed immediately after <code>scanf()</code>). Since there is already a <code>'\n'</code> in the buffer, your program won't appear to hang because it won't have to wait for input for <code>getchar()</code> to receive. Try it. :)</p> <p>For those who haven't a clue what that <code>scanf()</code> modifier does, here is a relevant excerpt from <a href="http://linux.die.net/man/3/scanf">http://linux.die.net/man/3/scanf</a> -</p> <blockquote> <p>[</p> <p>Matches a nonempty sequence of characters from the specified set of accepted characters; the next pointer must be a pointer to char, and there must be enough room for all the characters in the string, plus a terminating null byte. The usual skip of leading white space is suppressed. The string is to be made up of characters in (or not in) a particular set; the set is defined by the characters between the open bracket [ character and a close bracket ] character. The set excludes those characters if the first character after the open bracket is a circumflex (^). To include a close bracket in the set, make it the first character after the open bracket or the circumflex; any other position will end the set. The hyphen character - is also special; when placed between two other characters, it adds all intervening characters to the set. To include a hyphen, make it the last character before the final close bracket. For instance, [^]0-9-] means the set "everything except close bracket, zero through nine, and hyphen". The string ends with the appearance of a character not in the (or, with a circumflex, in) set or when the field width runs out.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload