String initialization

char *a = “Hi how are you??”
a[0] = ‘h’;

This will output Segmentation fault
Because, such an intialization will create const memory and it can’t be modified.

While

char a[] = “Hi how are you??”
a[0] = ‘h’

will give the desired output.

Leave a Reply

Your email address will not be published. Required fields are marked *