so_simple Posted May 22, 2008 at 05:27 PM Report Share #186749 Posted May 22, 2008 at 05:27 PM Eu tenho 2 listas e 2 apontadores para as listas. o que eu quero fazer é uma funcao para simplesmente mudar um nodo de uma lista para outra e "retornar" as cabecas das 2 listas. Como é que altero os ponteiros passados para a funcao? Link to comment Share on other sites More sharing options...
TheDark Posted May 22, 2008 at 05:29 PM Report Share #186750 Posted May 22, 2008 at 05:29 PM Como alteras os apontadores? Não percebi a dúvida... Desaparecido. Link to comment Share on other sites More sharing options...
so_simple Posted May 22, 2008 at 05:38 PM Author Report Share #186753 Posted May 22, 2008 at 05:38 PM ex: main(){ lista *A=NULL, *B=NULL; mudar_nodo(A,B); } void mudar_nodo(lista *A, lista *B){...} agora como mudo na funcao o valor do apontador da main?? Link to comment Share on other sites More sharing options...
Guest id194 Posted May 22, 2008 at 06:20 PM Report Share #186760 Posted May 22, 2008 at 06:20 PM mudar_nodo(A,B); lista *TMP; TMP = A; A = B; B = TMP; } Não percebi lá muito bem o problema e apontadores não é o meu forte, mas será que isto não serve? Link to comment Share on other sites More sharing options...
TheDark Posted May 22, 2008 at 06:46 PM Report Share #186764 Posted May 22, 2008 at 06:46 PM Se queres criar as listas na função e devolvê-las, tens que passar à função apontadores para apontadores: main(){ lista *A=NULL, *B=NULL; mudar_nodo(&A, &B); } void mudar_nodo(lista **A, lista **B){ *A = (lista *)malloc...; *B = (lista *)malloc...; ... } Desaparecido. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now