September 8th, 2012, 01:10 AM
Your problem is that you are not terminating your linked list chain correctly.
One way to fix:
1. Get rid of calling initLista() as you are simply allocating memory and not returning it, which causes a memory leak.
2. In main() call insere() like this instead:
/* initLista(); <--- Removed from code */
lst = insere(NULL, 40);
lst = insere(lst, 60);
lst = insere(lst, 80);
lst = insere(lst, 100);
When you call lst =insere(NULL, 40), you are telling it that the previous item is NULL, which properly terminates the list. Then your imprimi() rouitine should correctly work.
3. Your English is actually pretty good
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne