Tell me, please, what is the error, why the program does not open the file. The task of the program is to enter information about the product.
# include <stdio.h> # include <stdlib.h> # include <locale.h> # include <conio.h> # include <string.h> int main() { setlocale(LC_ALL, "Rus"); FILE *devices; struct measuredvalue { char name[50]; int upperbound; int lowerbound; int error; }; struct fullname { char firstname[50]; char secondname[50]; char surname[50]; }; struct address { char city[50]; char street[50]; int numberofhouse; }; struct customer { int listnumber; struct fullname fname; struct address addres; int amountofdevices; }; struct DEVICE { char name[50]; float cost; int num; int num1; struct measuredvalue *array; struct customer *buyer; }; int number, i, value1, j; printf("Кол-во товаров: "); scanf("%d", &number); struct DEVICE *mas; mas = (struct DEVICE*)malloc(number * sizeof(struct DEVICE)); if (!mas) { printf("Ошибка памяти"); } for (i = 0; i < number; i++) { printf("Наименование товара: "); gets(mas[i].name); gets(mas[i].name); printf("Стоимость товара: "); scanf("%f", &mas[i].cost); printf("Измеряющие величины: "); scanf("%d", &mas[i].num); mas[i].array = (struct measuredvalue*)malloc(mas[i].num * sizeof(struct measuredvalue)); for (j = 0; j < mas[i].num; j++) { scanf("%d", &value1); switch (value1) { case'1': strcpy(mas[i].array[j].name, "сила тока"); break; case'2': strcpy(mas[i].array[j].name, "напряжение"); break; case'3': strcpy(mas[i].array[j].name, "температура"); break; case'4': strcpy(mas[i].array[j].name, "давление"); break; case'5': strcpy(mas[i].array[j].name, "кислотность"); break; case'6': strcpy(mas[i].array[j].name, "концентрация серы"); break; case'7': strcpy(mas[i].array[j].name, "плотность"); break; } printf("Верхняя граница: "); scanf("%d", &mas[i].array[j].upperbound); printf("Нижняя граница: "); scanf("%d", &mas[i].array[j].lowerbound); printf("Погрешность"); scanf("%d", &mas[i].array[j].error); } printf("Кол-во заказчиков: "); scanf("%d", &mas[i].num1); mas[i].buyer = (struct customer*)malloc(mas[i].num1 * sizeof(struct customer)); for (j = 0; j < mas[i].num1; j++) { mas[i].buyer[j].listnumber = j + 1; printf("Фамилия "); gets(mas[i].buyer[j].fname.surname); printf("Имя "); gets(mas[i].buyer[j].fname.firstname); printf("Отчество "); gets(mas[i].buyer[j].fname.secondname); printf("Адрес: "); printf("город "); gets(mas[i].buyer[j].addres.city); printf("улица "); gets(mas[i].buyer[j].addres.street); printf("дом № "); scanf("%d", &mas[i].buyer[j].addres.numberofhouse); printf("Кол-во приборов: "); scanf("%d", &mas[i].buyer[j].amountofdevices); } } if ((devices = fopen("devices.txt", "w+")) != 0) { fprintf(devices, "Кол-во товаров: "); fprintf(devices, "%d", &number); for (i = 0; i < number; i++) { fprintf(devices, "Наименование товара: "); fputs(mas[i].name, devices); fprintf(devices, "Стоимость товара: "); fprintf(devices, "%f", &mas[i].cost); fprintf(devices, "Измеряющие величины: "); for (j = 0; j < mas[i].num; j++) { fputs(mas[i].array[j].name, devices); fprintf(devices, "Верхняя граница: "); fprintf(devices, "%d", &mas[i].array[j].upperbound); fprintf(devices, "Нижняя граница: "); fprintf(devices, "%d", &mas[i].array[j].lowerbound); fprintf(devices, "Погрешность"); fprintf(devices, "%d", &mas[i].array[j].error); } fprintf(devices, "Кол-во заказчиков: "); fprintf(devices, "%d", &mas[i].num1); for (j = 0; j < mas[i].num1; j++) { fprintf(devices, "%d", mas[i].buyer[j].listnumber); fprintf(devices, "Фамилия "); fputs(mas[i].buyer[j].fname.surname, devices); fprintf(devices, "Имя "); fputs(mas[i].buyer[j].fname.firstname, devices); fprintf(devices, "Отчество "); fputs(mas[i].buyer[j].fname.secondname, devices); fprintf(devices, "Адрес: "); fprintf(devices, "город "); fputs(mas[i].buyer[j].addres.city, devices); fprintf(devices, "улица "); fputs(mas[i].buyer[j].addres.street, devices); fprintf(devices, "дом № "); fprintf(devices, "%d", &mas[i].buyer[j].addres.numberofhouse); fprintf(devices, "Кол-во приборов: "); fprintf(devices, "%d", &mas[i].buyer[j].amountofdevices); } } fclose(devices); } else { printf("Ошибка открытия файла"); } getch(); return 0; } THANK.