Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I specify a variable width in a scanf() format string?

format specify String
0
Posted

How can I specify a variable width in a scanf() format string?

0

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.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.