Привет, я задаю вопрос о правописании из набора проблем 5 из cs50 и столкнулся с ошибкой сегментации, но я не понимаю, почему. Я получил следующую ошибку:
MISSPELLED WORDS
==18659== Invalid read of size 8
==18659== at 0x40102C: check (dictionary.c:32)
==18659== by 0x400C49: main (speller.c:112)
==18659== Address 0x75cfc8 is not stack'd, malloc'd or (recently) free'd
==18659==
==18659==
==18659== Process terminating with default action of signal 11 (SIGSEGV)
==18659== Access not within mapped region at address 0x75CFC8
==18659== at 0x40102C: check (dictionary.c:32)
==18659== by 0x400C49: main (speller.c:112)
==18659== If you believe this happened as a result of a stack
==18659== overflow in your program's main thread (unlikely but
==18659== possible), you can try to increase the size of the
==18659== main thread stack using the --main-stacksize= flag.
==18659== The main thread stack size used in this run was 8388608.
==18659==
==18659== HEAP SUMMARY:
==18659== in use at exit: 552 bytes in 1 blocks
==18659== total heap usage: 4 allocs, 3 frees, 6,224 bytes allocated
==18659==
==18659== 552 bytes in 1 blocks are still reachable in loss record 1 of 1
==18659== at 0x4C2FB0F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==18659== by 0x5258E49: __fopen_internal (iofopen.c:65)
==18659== by 0x5258E49: fopen@@GLIBC_2.2.5 (iofopen.c:89)
==18659== by 0x4009E3: main (speller.c:55)
==18659==
==18659== LEAK SUMMARY:
==18659== definitely lost: 0 bytes in 0 blocks
==18659== indirectly lost: 0 bytes in 0 blocks
==18659== possibly lost: 0 bytes in 0 blocks
==18659== still reachable: 552 bytes in 1 blocks
==18659== suppressed: 0 bytes in 0 blocks
==18659==
==18659== For counts of detected and suppressed errors, rerun with: -v
==18659== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
/etc/profile.d/cli.sh: line 94: 18659 Segmentation fault valgrind ./speller texts/cat.txt
Это мой код:
Я не понимаю, почему возникает ошибка сегментации, поскольку я предоставил некоторое время l oop для остановки, когда курсор находится в конце l oop , Может кто-нибудь сказать мне, где я ошибся, пожалуйста? Спасибо!