so_simple Posted May 22, 2008 Report Share Posted May 22, 2008 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 Report Share Posted May 22, 2008 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 Author Report Share Posted May 22, 2008 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 Report Share Posted May 22, 2008 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 Report Share Posted May 22, 2008 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