Would anybody be able to take a look and tell me why this code does not work as i have spent ages trying to correct 2 errors and cant find anything wrong with it. ( I am aware that there is not yet a complete if statement within the delete function but it should work as far as showing details and adding is concerned)
[CODE]#include <stdio.h>
#include <stdlib.h>
#define FALSE 0
#define TRUE 1
#define NAME 20
#define CODE 7
typedef struct house{
char surname[NAME];
char postcodeCode:;
int rooms;
int price;
}House;
void read(House arrayofrecs[], int *noofhouses);
void List(House arrayofrecs[], int *noofhouses);
void addhouse(House arrayofrecs[], int *noofhouses);
void deletehouse(House arrayofrecs[], int *noofhouses);
void main ()
{
house list[20];
int val;
int noinlist;
read(list, &noinlist);
printf("\nOPTIONS\n");
printf("1.Print the list of houses\n");
printf("2.Add a new house\n");
printf("3.Remove a house from list as specified by owner name\n");
printf("4.Output records to file\n");
printf("5.Calculate the average price of the houses\n");
printf("6.Output houses with the requested no.of rooms\n");
printf("Choose an option between 1 and 6\n");
scanf("%d", &val);
if (val==1)
List(list, &noinlist);
else if (val==2)
addhouse(list, &noinlist);
else if (val==3)
deletehouse(list, &noinlist);
void read(House arrayofrecs[], int *noofhouses) {
int i;
FILE *fp;
fp=fopen("a:\\House.txt","r");
printf("No on list?\n");
fscanf(fp, "%d", noofhouses);
i=0;
while(i<*noofhouses)
{
fscanf(fp, "%s %s %d %d", &arrayofrecs[i].surname, &arrayofrecs[i].postcode, &arrayofrecs[i].rooms, &arrayofrecs[i].price);
i++;
}
fclose(fp);
}
void List(House arrayofrecs[], int *noofhouses) {
int i;
printf("List of houses \n");
i=0;
while(i < noofhouses)
{
printf("%s\n %s\n %d\n %d\n", &arrayofrecs[i].surname, &arrayofrecs[i].postcode, &arrayofrecs[i].rooms, &arrayofrecs[i].price);
i++;
}
}
void addhouse(House arrayofrecs[], int *noofhouses) {
printf("\nAdd House\n");
printf("Owner Surname: ");
scanf("%s", arrayofrecs[].surname);
printf("\nPostcode: ");
scanf("%s", arrayofrecs[].postcode);
printf("\nNumber of rooms: ");
scanf("%d", arrayofrecs[].rooms);
printf("\nPrice: ");
scanf("%d", arrayofrecs[].price);
printf("\nHouse added");
List(list, noinlist);
}
void deletehouse(House arrayofrecs[], int noofhouses) {
char deletesurname[20], yn;
printf("\nDelete House\n");
printf("Surname: ");
scanf("%s", &deletesurname);
printf("\nDelete file? (y/n): ");
scanf("%s", &yn);
if (yn == 'y')
List(list, noinlist);
}
}