 <p>Just use <code>isalpha</code> to ignore other kinds of characters:</p> <pre><code>#include &lt;string.h&gt; #include &lt;stdio.h&gt; #include &lt;ctype.h&gt; int main (void) { char input[] = "thanks for the add"; int alpha_count = 0; for (int i = 0, x = strlen(input); i &lt; x; i++) { if (isalpha(input[i])) { if (alpha_count++ % 2 == 0 ) input [i] = toupper(input[i]); } } printf("%s\n", input); return 0; } </code></pre>