我正在試驗樹和節點,並遇到了麻煩。 我有組合樹和節點,值無法訪問
typedef struct nodo
{
int cuenta;
int fondo;
struct nodo *sig;
}pNodo;
typedef pNodo *tLista;
typedef struct tree
{
int RUT;
struct tree *izq;
struct tree *der;
struct nodo *tLista;
}tTree;
typedef tTree *tABB;
typedef tTree *tNodo;
void crearArbol(tABB arbol)
{
tABB nuevoA;
nuevoA=(tABB)malloc(sizeof(tTree));
arbol=nuevoA;
arbol->izq=NULL;
arbol->der=NULL;
}
int AgregarCuenta(tABB *arbol,int rut,int id_cuenta,int saldo)
{
tABB AUX;
AUX=*arbol;
tLista nuevaC;
int i=1;
if(AUX==NULL)
{
crearArbol(AUX);
if(id_cuenta==1)
{
(AUX->tLista)->fondo=saldo;
return 0;
}
else
{
return -1;
}
}
else
{
if(rut==AUX->RUT)
{
while(AUX->tLista!=NULL)
{
if(AUX->tLista->cuenta==id_cuenta)
{
return -1;
}
else
{
AUX->tLista=AUX->tLista->sig;
i++;
}
}
nuevaC=(tLista)malloc(sizeof(pNodo));
nuevaC->sig=NULL;
nuevaC->cuenta=i;
nuevaC->fondo=saldo;
AUX->tLista=nuevaC;
return 0;
}
else
{
if(rut<AUX->RUT)
{
AUX=AUX->izq;
AgregarCuenta(&AUX,rut,id_cuenta,saldo);
}
else
{
AUX=AUX->der;
AgregarCuenta(&AUX,rut,id_cuenta,saldo);
}
}
}
}
int main()
{
tABB arbolillo;
crearArbol(arbolillo);
AgregarCuenta(&arbolillo, 18020200, 1, 9999);
return 0;
}
它裸片上的 「(AUX-> tLista) - >豐多= saldo;」在AgregarCuenta功能。與「EXC_BAD_ACCESS」
我在做什麼錯?
這肯定會幫助,如果使用的代碼英文標識 – sehe 2011-05-15 23:18:44
@sehe:學習抽象... – 2011-05-15 23:20:46
@Jonathan閱讀代碼:我沒有說它不能做:)我想我是說:它現在阻止我讀取你的代碼 – sehe 2011-05-15 23:28:00