0

It's not working, can anyone explain?

#include <stdio.h>

int main()
{
    char *s="abcdef";
    *(s+2)='\0';
    printf("%d",s);
    return 0;
}
Passerby
  • 658
  • 1
  • 4
  • 9
  • 1
    Does this answer your question? [Why do I get a segmentation fault when writing to a "char \*s" initialized with a string literal, but not "char s\[\]"?](https://stackoverflow.com/questions/164194/why-do-i-get-a-segmentation-fault-when-writing-to-a-char-s-initialized-with-a) – Passerby Dec 09 '21 at 04:35

0 Answers0