char * temp = cstring; while( *temp ) { if( *temp == '-' ) *temp = '_'; temp++; }