I'm having some problems with this simple code:
Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct make_point {
int x;
int y;
char name[4];
}point;
struct nodea {
point naero;
struct nodea *prox;
};
typedef struct nodea *listap;
void insere_point(listap x, point novo_point)
{
listap t = (listap) malloc(sizeof(listap));
t->naero = novo_point;
t->prox = x->prox;
x->prox = t;
}
main()
{
listap total_point;
point novo;
scanf ("%d%d%s",&novo.x,&novo.y,novo.name);
insere_point (total_point,novo);
printf ("%d%d%s\n",total_point->naero.x,total_point->naero.y,total_point->naero.name);
}
As you can see I just want to do a simple scan and print to and from a list, and when i put this on the standard input "3 15 FRA" i get a random number instead of 3 15 FRA. I've been trying from quite some time to find my mistake but i still can't do this, anyone got a hint to what i'm doing wrong?