Main(){ char *p = "hello world"; p[0] = 'H'; printf("%s", p);}

A) Compile error
B) “Hello world”
C) Runtime error.
D) “hello world”

Showing Answers 1 - 19 of 19 Answers

mef526

  • Feb 13th, 2006
 

This is generally true, except ion many embedded systems, where the static allocation to a pointer will end up in the constant, non volatile (that is, non-modifiable ROM) memory. In that case it could give either a complile error, or a runtime error if the compiler is not good enough to catch th modification of nonvolitile memory

  Was this answer useful?  Yes

paulson paul chambakottukudyil

  • Apr 18th, 2006
 

It will give a run time error.

  Was this answer useful?  Yes

Anup Kumar Saha

  • Nov 6th, 2006
 

hi...all.......this program will show segmentation fault.

  Was this answer useful?  Yes

Basically, this will result in runtime error. Because when you use statement like:

char *p = "Hello world";

The space for hello word gets created in code segment only which can not be modified.

sittoop

  • Feb 25th, 2009
 

Latest compilers will give a warning saying
warning: deprecated conversion from string constant to ‘char*’
and it is a Segmentation fault.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions