różnica między char * i char [] z strcpy ()
Przez ostatnie kilka godzin miałem problem z problemem, który zrozumiałem. Oto mój problem:
void cut_str(char* entry, int offset) {
strcpy(entry, entry + offset);
}
char works[128] = "example1\0";
char* doesnt = "example2\0";
printf("output:\n");
cut_str(works, 2);
printf("%s\n", works);
cut_str(doesnt, 2);
printf("%s\n", doesnt);
// output:
// ample1
// Segmentation: fault
Czuję, że jest coś ważnego w char * / char [], którego tu nie dostaję.