1

What is the difference between these two declarations ?

char *format = "sss jj mmm aaaa hh:mm::ss\n";
char format[] = "sss jj mmm aaaa hh:mm::ss\n";

In fact, the difference I saw is that with the * declaration I can't use strncopy with format as destination ( bus error ), but with the [] declaration I can use strncopy without problems.

What can explain this behavior ?

NathanVss
  • 634
  • 5
  • 16
  • duplicate http://stackoverflow.com/q/1704407/612920 – Mansuro Sep 15 '16 at 13:58
  • Also see [this](http://stackoverflow.com/questions/30533439/string-literals-vs-array-of-char-when-initializing-a-pointer) – Eugene Sh. Sep 15 '16 at 14:04
  • Better duplicate: http://stackoverflow.com/questions/164194/why-do-i-get-a-segmentation-fault-when-writing-to-a-string-initialized-with-cha – Lundin Sep 15 '16 at 14:11

0 Answers0