void change(char* input){
  memset(input, 'a', strlen(input));
}

int main(){
  char* p = "foo";
  cout << p << endl;
  change(p);
  cout << p << endl;
}

p is a pointer to read-only memory. While some compilers might allow it to be modified, technically what you're doing is undefined behavior. Change line 6 to char p[] = "foo"; and it should work just fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.