in Programming in C edited by
606 views
0 votes
0 votes

According to me Option D.

Because it should be an error because *("INDIA" + 2 ) = 'D' and we are doing 'D' = 'I' which is not valid so Error ???

But answer is C

in Programming in C edited by
by
606 views

4 Comments

printf("%c",*("INDIA"+2)='I'); // 'I'

 printf("%s",*("INDIA"+2)='I'); // segementation fault
0
0
"INDIA" represent a base address of string constant assume address is 1000.

now by doing *("INDIA"+2)='I' you are trying to modify string constant which is not allowed, Hence segmentation fault.
0
0
@anu007 India is in double quote ... does it make any sense ??
0
0

1 Answer

3 votes
3 votes
Best answer

Attempting to write on Read-only location is a segmentation fault but not the error...

 

segmentation fault means Abnormal termination of Program.

 

read more on Segmentation fault https://en.wikipedia.org/wiki/Segmentation_fault

selected by

1 comment

Thanx Brother
0
0