Well ok, here's the whole function. I do have the include statement, but the funny thing is that the program uses that syntax and same statement in a dozen other places in the program, and the compiler doesn't care. One wierd thing also, is that it's saying that a statement that clearly has a semicolon, does not.
Here is the code for the products structure. It's located above the main function.
Code:
typedef struct
{
int prodnum, prodtype, prodquan;
double prodcost, prodprice;
char proddesc[81];
} products;
Code:
void change()
{
FILE *limitfile = fopen("limits.txt", "r");
double l1, l2, l3, l4, l5, l6, l7, l8, l9, l10;
/*Assign values to the limit variables.*/
fscanf(limitfile, "%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", &l1, &l2, &l3, &l4, &l5, &l6, &l7, &l8, &l9, &l10);
fclose(limitfile);
products product_list3;
int y=0;
int x=0;
char z;
printf("\n\nEnter the record number you wish to change. : ");
scanf("%d", &y);
FILE *fp = fopen("products.txt", "rb");
fread(&product_list3, sizeof(product_list3), y, fp);
fclose(fp);
if (product_list3.prodtype == 0)
{
printf("\n\nRecord is deleted. Would you like to restore it? y/n: ");
scanf("%c", &z);
if (z=='y')
{
printf("\n\nEnter a new product type : ");
product_list3.prodtype = getint(l3, l4);
}
else break;
}
else
{
printf("\n\nEnter the option you wish to change:");
printf("\n1. Product Number\n2. Product Type\n3. Product Description\n4. Product Quantity\n5. Product Cost\n6. Product Price.\n");
while (x<1 || x>6)
{
printf("\n:: ");
scanf("%d", &x);
}
printf("\n\nEnter new value. : ");
switch(x)
{
case 1 :
product_list3.prodnum = getint(l1, l2);
break;
case 2 :
product_list3.prodtype = getint(l3, l4);
break;
case 3 :
getstring(product_list3.proddesc);
strmorph(product_list3.proddesc);
break;
case 4 :
product_list3.prodquan = getint(l5, l6);
break;
case 5 :
product_list3.prodcost = getreal(l7, l8);
break;
case 6 :
product_list3.prodprice = getreal(l9, l10);
break;
}
}
fp = fopen("products.txt", "ab");
fwrite(&product_list3, sizeof(product_list3), y, fp);
fclose(fp);
printf("\n\nChange successful.");
}