 <p>You can simply extend your code: </p> <pre><code>if ( (str[i] == '-' &amp;&amp; minus) || (str[i] &gt;= '0' &amp;&amp; str[i] &lt;= '9') || (str[i] == 'e' || str[i] == 'E') ) </code></pre> <p>to </p> <pre><code>char separator = ','; //or whatever you want int have_separator = 0; if ( (str[i] == '-' &amp;&amp; minus) || (str[i] &gt;= '0' &amp;&amp; str[i] &lt;= '9') || (str[i] == 'e' || str[i] == 'E') || str[i] == separator ) { if (str[i] == separator &amp;&amp; have_separator == 0) { have_separator = 1; str_dbl[j++] = str[i]; continue; } ... </code></pre> <p>Please note that this is only some try to show the idea - not the real working code (but it could work anyway). You can use similar concept. </p>