It's because you are trying to change a string constant.
#include <stdio.h>
#include <stdlib.h>
int main(void)
{ char c[12] = "xxx...xxx";
sprintf(&c[3], "%d", 123);
printf(c); // should print: xxx123
return 0;
}
Or, most correctly....
#include <stdio.h>
#include <stdlib.h>
int main(void)
{ char c[8];
sprintf(c, "xxx%d", 123);
printf(c); // should print: xxx123
return 0;
}