Hi (again)
Hope this is my last post asking some help...
I have a function to see my registered players but i must use malloc
my struct isCode:int listarTop() { struct jogador *j; int retorno, cont = 0; FILE *f; if ((f= fopen("registos.dat", "rb")) == NULL) { printf("Erro ao abrir ficheiro\n"); } else { j=(struct jogador *)malloc(sizeof(struct jogador)); if (j==NULL) { printf("Erro na alocacao de memoria!"); exit (1); } printf("\nNome: %s",j->nome); printf("\nNickname : %s",j->nick); printf("\nPassword : %s",j->pass); printf("\nLog : %d",j->log); printf("\n"); } free(j); fclose(f); return 0; }
char nome[100];
char nick[100];
char pass[100];
int log;
Well, i have no errors but the prints are strange characters
What's wrong?



LinkBack URL
About LinkBacks


