Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Learn to use valgrind. This is one of the most useful tool to diagnose these kind of errors.</p> <p><code><pre> $valgrind ./a.out "HOLA MUNDO COMO s" ==4949== Memcheck, a memory error detector ==4949== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==4949== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info ==4949== Command: ./a.out HOLA\ MUNDO\ COMO\ s ==4949== Cadena: 'HOLA MUNDO COMO s' ==4949== Invalid write of size 8 ==4949== at 0x40070B: split (a.c:20) ==4949== by 0x40076B: main (a.c:32) ==4949== Address 0x518a098 is 0 bytes after a block of size 8 alloc'd ==4949== at 0x4C245E2: realloc (vg_replace_malloc.c:525) ==4949== by 0x4006DC: split (a.c:17) ==4949== by 0x40076B: main (a.c:32) ==4949== ----------------TOKENS------------ ==4949== Conditional jump or move depends on uninitialised value(s) ==4949== at 0x4007BF: main (a.c:35) </pre></code></p> <p>what this thing says, is that, on line 20, you tried to write à pointer after the end of your table.</p> <p>which is true : you allocate a table of size i+1, then you increment i and you access table[i], which is not allocated. For example, The first time you enter the loop, you reallocate a table of 1 chars* (so you're not growing it), and you access a second element of your table. the second time you enter the loop, you grow your array to a size of 2 and you access the third element/</p> <p>the second error, on line 35, mean that your MILISTA table have some parts that are not initialized because of the wrong behaviour of the first loop.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload