How to read / parse input in C? The FAQ
<p>I have problems with my C program when I try to read / parse input.</p>

<p>Help?</p>

<hr>

<p>This is a FAQ entry.</p>

<p>StackOverflow has <em>many</em> questions related to reading input in C, with answers usually focussed on the specific problem of that particular user without really painting the whole picture.</p>

<p>This is an attempt to cover a number of common mistakes comprehensively, so this specific family of questions can be answered simply by marking them as duplicates of this one:</p>

<ul>
<li>Why does the last line print twice?</li>
<li>Why does my <code>scanf("%d", ...)</code> / <code>scanf("%c", ...)</code> fail?</li>
<li>Why does <code>gets()</code> crash?</li>
<li>...</li>
</ul>

<p>The answer is marked as community wiki. Feel free to improve and (cautiously) extend.</p>