[C] realloc 에러

kyliecamila·2022년 7월 26일
0

C

목록 보기
1/2

C로 자료구조 문제를 풀다가 생긴 에러가 있다.
realloc을 사용했을 때 나타난 문제다.

warning: ignoring return value of ‘realloc’, declared with attribute warn_unused_resul

realloc을 하면 기존보다 더 많은 메모리를 할당받을 때 주소가 바뀌는 경우가 있어서 그 주소값을 다른 곳에 저장하고 다시 사용해야한다고 한다.

https://www.codestudyblog.com/questions/sf/0421201641.html

그래서 storeHere = realloc(str,memorySize);
이런식으로 정의하면 에러가 나지 않는다.

0개의 댓글