c - Dereferencing char pointer causes segfault -


i using strchr find point in buffer = encountered. changing equal character m. segfault @ line try this.

this full code:

int main(void){     char *buffer = "name=tom"     char *pointer;     pointer = strchr(buffer,'=');     *pointer = 'm';    <--------- segfault occurs here return (0); } 

i following error segfault:

process terminating default action of signal 11 (sigsegv)  bad permissions mapperd region @ addresss ..... 

you not checking return value of strchr, null since don't see input.

in addition this, , how buffer declared? not char* can modified, since stored in data segment of binary (as string literal).


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -