Jump to content

[C] Ajuda: problema com apontadores (Resolvido)


Recommended Posts

Posted

Boas,

'Tou a ter aki um dakeles problemas chatos e q n percebo a razão pq n consigo fazer este pedacito de codigo funcionar.

Tou a usar o gcc em cygwin (gcc version 3.4.4 (cygming special) (gdc 0.12, using dmd 0.125))

um pedaço de codigo problematico é este:

 typedef struct STRUCT_NODE_RAIZ {
        struct RAIZ_NODE *prox;
        struct BUCKET *filho;
} RAIZ_NODE;

typedef struct STRUCT_RAIZ_BUCKET {
        int n;
        struct RAIZ_NODE *data;
} RAIZ_BUCKET;


int inserir (RAIZ_BUCKET* raiz) {

        RAIZ_NODE *rn;

        rn=(RAIZ_NODE*)malloc (sizeof(RAIZ_NODE));

        raiz->data=rn;
        return 0;
}

o output do gcc:

argh.c: In function `inserir':

argh.c:20: warning: assignment from incompatible pointer type

Alguem me pode dar uma dica? estive a ver nos manuais e estou a fazer tudo como lá é dito (ou tou a ficar cegueta???)

cumps

Posted

podias usar o GeSHi, não?

assim à primeira vista diria que tens aqui um erro...

typedef struct STRUCT_NODE_RAIZ {
        struct RAIZ_NODE *prox;   // não devia ser 'struct STRUCT_NODE_RAIZ'  ?
        struct BUCKET *filho;
} RAIZ_NODE;

typedef struct STRUCT_RAIZ_BUCKET {
        int n;
        struct RAIZ_NODE *data;   // penso que o 'struct' está a mais
} RAIZ_BUCKET;
Posted

aumm.. eu tb achei estranho esses structs todos..lol obrigadao 😛

parece q só se usa quando é um "link" para o mesmo struct...

OBRIGADO 👍

vou ver do geshi.. n conheço 😄

podias usar o GeSHi, não?

assim à primeira vista diria que tens aqui um erro...

typedef struct STRUCT_NODE_RAIZ {
        struct RAIZ_NODE *prox;
        struct BUCKET *filho;
} RAIZ_NODE;

typedef struct STRUCT_RAIZ_BUCKET {
        int n;
        struct RAIZ_NODE *data;   // penso que o 'struct' está a mais
} RAIZ_BUCKET;

Posted

fiz uma correcção no outro post...


vou ver do geshi.. n conheço 👍

o GeSHi permite-te colocar código aqui no fórum com cores, tal como o que eu coloquei.

para isso usas as tags [ code=c ] e [ /code ] (sem espaços)

Posted

em relação à outra correção... tens razão... bolas tou todo confundido...

se te disser q estou a implementar uma b+ e a fazer erros destes chamas-me maluco 👍

obrigado 😛

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.