1 / 1 / 6
Регистрация: 12.12.2014
Сообщений: 50
|
||||||
1 | ||||||
Error in function20.09.2016, 17:50. Показов 952. Ответов 3
Метки нет (Все метки)
Если Progonka(...) в окремой функции - не работает. Если код из функции скопировать в main() все работает.
Код ->
0
|
20.09.2016, 17:50 | |
Ответы с готовыми решениями:
3
Error: too few arguments to function 'pow' [Error] too few arguments to function 'pow'? Error C4996: 'scanf': This function or variable may be unsafe Error C2668: 'pow': ambiguous call to overloaded function |
1786 / 1036 / 445
Регистрация: 12.05.2016
Сообщений: 2,550
|
|
21.09.2016, 03:57 | 2 |
Если у Вас что-то не работает, пишите ошибки, которые выдает компилятор.
У вас на этапе компиляции не понятно сколько памяти выделять под массив. free() делается для всех указателей полученных с помощью malloc().
0
|
1 / 1 / 6
Регистрация: 12.12.2014
Сообщений: 50
|
|
21.09.2016, 22:08 [ТС] | 3 |
gcc -Wall -pedantic -std=c11 -g *.c && valgrind --leak-check=full --track-origins=yes ./a.out
==24704== Memcheck, a memory error detector ==24704== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. ==24704== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info ==24704== Command: ./a.out ==24704== A matrix ==24704== Conditional jump or move depends on uninitialised value(s) ==24704== at 0x4E8A6A8: __printf_fp (printf_fp.c:379) ==24704== by 0x4E89078: vfprintf (vfprintf.c:1631) ==24704== by 0x4E8F848: printf (printf.c:33) ==24704== by 0x4008EE: main (main.c:38) ==24704== Uninitialised value was created by a heap allocation ==24704== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==24704== by 0x400710: main (main.c:13) Syscall param write(buf) points to uninitialised byte(s) ==24704== at 0x4F30A10: __write_nocancel (syscall-template.S:84) ==24704== by 0x4EB2B2E: _IO_file_write@@GLIBC_2.2.5 (fileops.c:1263) ==24704== by 0x4EB4338: new_do_write (fileops.c:518) ==24704== by 0x4EB4338: _IO_do_write@@GLIBC_2.2.5 (fileops.c:494) ==24704== by 0x4EB474A: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:859) ==24704== by 0x4EAB2C7: putchar (putchar.c:28) ==24704== by 0x400904: main (main.c:40) ==24704== Address 0x52032f8 is 24 bytes inside a block of size 1,024 alloc'd ==24704== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==24704== by 0x4EA7184: _IO_file_doallocate (filedoalloc.c:127) ==24704== by 0x4EB54C3: _IO_doallocbuf (genops.c:398) ==24704== by 0x4EB4827: _IO_file_overflow@@GLIBC_2.2.5 (fileops.c:820) ==24704== by 0x4EB31BC: _IO_file_xsputn@@GLIBC_2.2.5 (fileops.c:1331) ==24704== by 0x4EA9677: puts (ioputs.c:40) ==24704== by 0x40089D: main (main.c:34) ==24704== Uninitialised value was created by a heap allocation ==24704== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==24704== by 0x400710: main (main.c:13) ==24704== 1.000000 2.000000 0.000000 0.000000 1.000000 10.000000 -5.000000 0.000000 0.000000 1.000000 -5.000000 2.000000 0.000000 0.000000 1.000000 4.000000 ==24704== Invalid read of size 8 ==24704== at 0x400B69: Progonka (main.c:71) ==24704== by 0x400926: main (main.c:44) ==24704== Address 0x52031e0 is 0 bytes after a block of size 32 alloc'd ==24704== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==24704== by 0x400710: main (main.c:13) ==24704== ==24704== Invalid read of size 8 ==24704== at 0x400D16: Progonka (main.c:75) ==24704== by 0x400926: main (main.c:44) ==24704== Address 0x5203240 is 0 bytes after a block of size 32 alloc'd ==24704== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==24704== by 0x400730: main (main.c:17) ==24704== ==24704== Invalid read of size 8 ==24704== at 0x400D2E: Progonka (main.c:75) ==24704== by 0x400926: main (main.c:44) ==24704== Address 0x5203060 is 0 bytes after a block of size 32 alloc'd ==24704== at 0x4C2DB8F: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==24704== by 0x4006DD: main (main.c:10) ==24704== ==24704== Invalid read of size 8 ==24704== at 0x400D42: Progonka (main.c:75) ==24704== by 0x400926: main (main.c:44) ==24704== Address 0x18 is not stack'd, malloc'd or (recently) free'd ==24704== ==24704== ==24704== Process terminating with default action of signal 11 (SIGSEGV) ==24704== Access not within mapped region at address 0x18 ==24704== at 0x400D42: Progonka (main.c:75) ==24704== by 0x400926: main (main.c:44) ==24704== If you believe this happened as a result of a stack ==24704== overflow in your program's main thread (unlikely but ==24704== possible), you can try to increase the size of the ==24704== main thread stack using the --main-stacksize= flag. ==24704== The main thread stack size used in this run was 8388608.
0
|
1786 / 1036 / 445
Регистрация: 12.05.2016
Сообщений: 2,550
|
|
22.09.2016, 05:45 | 4 |
Смотрим
В цикле вы пытаетесь получить элемент массива по индексу i+1, на последней итерации у вас выход за границу массива.
2
|
22.09.2016, 05:45 | |
22.09.2016, 05:45 | |
Помогаю со студенческими работами здесь
4
Ошибка 1 error C4996: 'fopen': This function or variable may be unsafe Error C2064: term does not evaluate to a function taking 1 arguments Ошибка: error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. Ошибка в поиске седловых точек: Error C2447: missing function header Искать еще темы с ответами Или воспользуйтесь поиском по форуму: |