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



    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 << str << "\t";
    }
    
    int main(){
    
    	replace("Hello World",'_');
    
    	return 0;
    }
Error in my function code (stop working)
===

I have runtime error and I don't know what's the reason .



    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 << str << "\t";
    }
    
    int main(){
    
    	replace("Hello World",'_');
    
    	return 0;
    }