I'm importing data from a text file to a linked list, but fscanf
gives weird numbers.
My structure:
struct arac
{
struct arac *next;
char marka[15];
char model[15];
char paket[15];
char renk[10];
int yil;
char motor[8];
char sanz[3];
int km;
int kayitno;
};
And also this is my adding function:
struct arac *aktar(struct arac *go)
{
FILE *imptr = fopen("Yenikayit.txt","r");
if(imptr==NULL)
{
printf("\nDosya bulunamadi.");
return NULL;
}
else
{
while(feof(imptr)!=0)
{
go=(arac*)malloc(sizeof(arac));
fscanf(imptr,"\n%d %d %s %s %s %s %d %s %s",go->kayitno, go->km, go->marka, go->model, go->paket, go->renk, go->yil, go->motor, go->sanz);
printf("\n%d %d %s %s %s %s %d %s %s", go->kayitno, go->km, go->marka, go->model, go->paket, go->renk, go->yil, go->motor, go->sanz);
go->next=NULL;
go=go->next;
}
}
}
Embedded the printf
for debugging, so it's giving this output, and program crashes:
947398688 1929405816 S>,│Aæz rs\Berk Ízel\Desktop\otm-final\otm-final.exe sktop\otm-final\otm-final.exe 1818324585 \otm-final.exe al.exe
1207974467 1027954249 \Berk Ízel\Desktop\otm-final\otm-final.exe top\otm-final\otm-final.exe tm-final.exe (x88,│Gùz 1446944