-1
#include<stdio.h>

char* output;
int main() {
output="Hello";
output[0]='r'; // This line shows error . Please assist as to why 
printf(output);
return 0;
}

Please tell the correct way to do so . I know this might be a stupid question for most of the people , but I wanted to perform an operation like this (the line with comment ) ,so this is just a short example of the problem that i am facing.

Thank You

1 Answers1

0

When you write:

output = "Hello";

Then char pointer output points to a string. By their very nature strings are immutable objects.

bhavesh
  • 1,343
  • 2
  • 14
  • 23