Error in my function code (stop working)
<p>I have runtime error and I don't know what's the reason .</p>

<pre><code>void replace(char *str, char ch){
    int i=0;
    while(*(str+i) != '\0'){
        if(*(str+i) == ' '){
            *(str+i) = ch;  // I doubt in this line
        }
        i++;
    }   
    cout &lt;&lt; str &lt;&lt; "\t";
}

int main(){

    replace("Hello World",'_');

    return 0;
}
</code></pre>
