unsigned char** Files::del_mass(const int n, unsigned char** mass)
{
	int i;
	for (int i = 0; i < n; i = i + 1)//освобождение памяти массива A 
		delete[] mass[i];
	delete[] mass;
	return 0;
}
unsigned char** Files::new_mass(const int n)
{
	int i;
	unsigned char** mass = new unsigned char*[n];//массив указателей 
	for (i = 0; i < n; i = i + 1)//выделение памяти 
	{
		mass[i] = new unsigned char[n];
	}
	return mass;
}
std::string dv(unsigned long long num)
{
	std::string bin;

	while (num != 0)
	{
		bin = char((num & 0x01) + '0') + bin;

		num >>= 1;
	}

	return bin;
}
unsigned char** Files::open()
{
	printf("Введите имя файла: ");
	gets_s(n_txt);
	if (strchr(n_txt, '.') == NULL) strcat_s(n_txt, ".txt");
	f_txt = fopen(n_txt, "r");
	return 0;
} //открытие существующего файла
char Files::create()
{
	cout << "Введите имя файла для сохранения: " << endl;
	cin >> n_dat;
	if (strchr(n_dat, '.') == NULL) strcat(n_dat, ".dat");
	f_dat = fopen(n_dat, "w");
	if (!(f_dat))
	{
		cout << "Все хуево" << endl;
		system("PAUSE");
		exit(1);
	}

}
unsigned char** Files::work()
{
	/*int c;
	for (int i; i < n; i++)
	{
		c = mass[i];
		cout << c << " ";
	}
	cout << endl;*/
	if (!f_txt)
	{
		printf("Ошибка открытия.\n");
		system("pause");
		exit(1);
		//return NULL;
	}
	fscanf(f_txt, "%i", &n);
	unsigned char** mass = new_mass(n);
	if (!mass)
	{
		fclose(f_txt);
		system("pause");
		exit(1);
		//return NULL;
	}
	for (int i = 0; i < n; i++)
	{
		{
			if (fscanf(f_txt, " %c", &mass[i]) != 1)
			{
				printf("Ошибка чтения.\n");
				mass = del_mass(n, mass);
				//fclose(f_txt);
				system("pause");
				exit(1);
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		printf("%c ", mass[i]);
		//cout << mass[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < n; i++)
	{
		int d = atoi(mass[i]);
		//printf("%c %i ", mass[i], mass[i]);
	}
	cout << endl;
	fclose(f_txt);

	/*for (int i = 0; i < n; i++)
	{
		int c = *mass[i];
		cout << c << " ";
		//cout << c << " ";
		//cout << dv(c) << " " << endl;
	}
	cout << endl;*/
	return mass;
}