0

In a C program, suppose I have a char array and a char pointer.

1.

char word[6] = "HELLO";
word[1] = 'A';

2.

char * word = "HELLO";
word[1] = 'A';

Why cant't we update the word using the 2nd method but can with 1st?

Note: Using 2nd method, though the program compiles there is a

Segmentation fault

error.

arnieM
  • 93
  • 1
  • 9

0 Answers0