Okay, I've got a small problem going on. Here goes.
Code:
struct CD {
unsigned int ID;
char *Title;
char *Artist;
char *Genre;
int Year;
int Time;
int Number_Tracks;
struct Songs *Track_Ptr;
};
void dbload()
{
char dbname[MAXFILELEN];
FILE *fp1;
int cdnum;
int i;
struct CD CDray, *ptr;
ptr = &CDray;
printf("Enter file to load: ");
scanf("%s", &dbname);
if ((fp1 = fopen(dbname, "r")) == NULL)
{
printf("Cannot open file\n");
return;
}
fscanf(fp1, "%x\t", ptr->ID);
printf("%d",&ptr->ID);
printf("Load successful\n");
}
ID inside the file should be a hex number, for example: 820c100a
I know %x should read it in, but it crashes each time at that point. Also, when I print it, I want to print it as a hex number, which should again be %x unless I'm mistaken.
Any ideas why I'm crashing?