title: Execution of printf() and Segmentation Fault
body: <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      char *name = "Vikram";
      printf("%s",name);
      name[1]='s';
      printf("%s",name);
      return 0;
  }
  </code></pre>
  
  <p>There is no output printed on terminal and just get segmentation fault. But when I run it in GDB, I get following -</p>
  
  <pre><code>Program received signal SIGSEGV, Segmentation fault.
  0x0000000000400525 in main () at seg2.c:7
  7       name[1]='s';
  (gdb) 
  </code></pre>
  
  <p>This means program receive SEG fault on 7th line (obviously I can't write on constant char array) . Then why printf() of line number 6 is not executed ?</p>