Start structure pointer with an address?

7

I would like to know if it is possible to start this pointer type structure with an address, without needing to point to another variable, or allocate memory.

typedef struct{

    char nome[20];
    int idade;

}pessoa;


pessoa leonardo;
pessoa *p;

p = &leonardo;
p->idade = 23;
printf("%d", p->idade);

Or allocating memory.

pessoa *p = malloc(sizeof(pessoa));
    
asked by anonymous 28.09.2016 / 15:09

1 answer

6

You can:

p = (pessoa*)1234;

Now, you have to know what you're going to do with it ...

    
28.09.2016 / 15:23