How can I specify a variable width in a scanf() format string?
You can’t. 12.17: When I read numbers from the keyboard with scanf “%d\n”, it seems to hang until I type one extra line of input. A: Try using “%d” instead of “%d\n”. 12.18: I’m reading a number with scanf %d and then a string with gets(), but the compiler seems to be skipping the call to gets()! A: scanf() and gets() do not work well together. 12.19: I’m re-prompting the user if scanf() fails, but sometimes it seems to go into an infinite loop. A: scanf() tends to “jam” on bad input since it does not discard it.