[C언어] "Segmentation fault (core dumped)" 해결


[C언어]

문제상황: 실무에서 사용될 수 있는 C언어 코드를 작성 중 다음과 같은 에러가 발생했습니다. 아래 코드에서 에러가 발생한 부분과 에러 로그를 확인해봅시다. #include #include #include void reverse_string(char *str) { int length = strlen(str); char *temp = (char *)malloc(sizeof(char) * (length + 1)); for (int i = 0; i < length; i++) { temp[length - i - 1] = str[i]; } strcpy(str, temp); } int main() { char *input = "Hello, C!"; reverse_string(input); printf("Reverse..


원문링크 : [C언어] "Segmentation fault (core dumped)" 해결