I am trying to find a way to load my file into a series of structures and then display the results out onto the screen but i seem to hit the infinite loop as the files isnt actually being read, any thoughts on how to get my file to load to it?
Code:
struct area_type
{
int num_of_area;
char address_of_area[200];
char firstname[100];
char surname[100];
int num_of_location;
float price;
} area_type;
int main()
{
struct area_type * book_type;
int numCounter;
char filepath[256] ="";
printf("Please enter the full path of the file to be loaded: %s", filepath);
scanf("%s", filepath);
getchar();
FILE * fptr;
if (((fptr = fopen(filepath,"r"))))
{
printf("The file has opened sucessfully for reading\n");
while (fread(&area_type, sizeof area_type, 1, fptr) == 1)
book_type = (struct area_type*) malloc(sizeof(struct * area_type) *numCounter);
int i = 0;
{
for (i = 0; i < numCounter; i++)
{
printf("Area:%d, Address:%s, First name:%s, Surname:%s, Loaction:%d, Price:%f\n",
book_type[i].num_of_properties, book_type[i].address_of_property,
book_type[i].estate_firstname, book_type[i].estate_surname,
book_type[i].num_of_bedrooms, book_type[i].price_property);
}
}
}