@HayterWayper

У меня возникает ошибка fatal error: carti.h: no such file or directory?

Код
#include <iostream>
#include <fstream>
#include <cstring>
#include <iomanip>
#include "carti.h"
using namespcae std;

void readBook();
void showBook();
void rewriteBook();
void addBook();
void dellBook();
void oldBook();
void newBook();

struct books
{
	char CodCarte[5];
	char NumAutor[15];
	char PrenAutor[25];
	char Titlu[20];
	int AnEd;
	float PretC;
}book[50];

void readBook()
{
	int i = 0;
	ifstream f("carti.txt");
	while (!in.eof())
	{
		f >> book[i].CodCarte;
		f >> book[i].NumAutor;
		f >> book[i].PrenAutor;
		f >> book[i].Titlu;
		f >> book[i].AnEd;
		f >> book[i].PretC;

		if (!f.eof())
			i++;
	}
	n = i;
	f.close();
}

void showBook()
{
	for (int i = 0; i < n; i++)
	{
		cout << endl << left << setw(5) << book[i].CodCarte << setw(10) << book[i].NumAutor
			<< setw(15) << book[i].PrenAutor << setw(20) << book[i].Titlu
			<< setw(5) << book[i].AnEd << setw(5) << book[i].PretC << endl; 
	}
}

void rewriteBook()
{
	ofstream f("carti.txt");

	for ( int i = 0; i < n; i++)
	{
		f << book[i].CodCarte << " " << book[i].NumAutor << " "
		  << book[i].PrenAutor << " " << book[i].Titlu
		  << " " << book[i].AnEd << " " << book[i].PretC << endl;
	}
	f.close();
}

void addBook()
{
	books x;
	int poz;
	cout << "Input info about new book: \n";
	cout << "Caod: ";
	cin >> x.CodCarte;
	cout << "Nume autor: ";
	cin >> x.NumAutor;
	cout << "Prenume autor:";
	cin >> x.PrenAutor;
	cout << "Titlul: ";
	cin >> x.Titlu;
	cout << "Anul: ";
	cin >> x.AnEd;
	cout << "Pret: ";
	cin >> x.PretC;
	cout << "Input pozition: "
	cin >> poz;
	poz--;

	if (poz > 0 && poz <= n)
	{
		n++;
		for ( int i = n - 1; i >= poz; i--)
		{
			book[i] = book[i - 1];
			book[poz] = x;

			rewriteBook();
		}
	}
	else
		cout << "there are " << n << "quantity" << endl;
}

void delBook()
{
	books x;
	char cod[20];

	cout << "Input code if book for deleting";
	cin >> cod;
	int poz = -1;
	for (int i = 0; i < n; i++)
	{//posibil va trebui de sters granita la for
		if (!strcmp(book[i].CodCarte, cod)
		
			poz=i;
		
		if (poz==-1)
		
			cout<<"There is no such book"<<endl;
		
		else
		{
			n--;
			for (int i = poz; i < n; i++)
				book[i] = book[i + 1];

			rewriteBook();
		}
	}

}

void oldBook()
{
	int old = book[0].AnEd;
	for (int i = 1; i < n; i++)
		if (book[i].AnEd < old)
			old = book[i].AnEd;

	for (int i = 0; i < n; i++)
		if (book[i].AnEd == old)
			cout<< book[i].CodCarte << "/t" << book[i].NumAutor << "/t"
			<< book[i].PrenAutor << "/t" << book[i].Titlu
			<< "/t" << book[i].AnEd << "/t" << book[i].PretC << endl;
}

void newBook()
{
	float new = book[0].AnEd;
	for (int i = 1; i < n; i++)
		if (book[i].AnEd > new )
			new = book[i].AnEd;

	for (int i = 0; i < n; i++)
		if (book[i].AnEd == new)
			cout << book[i].CodCarte << "/t" << book[i].NumAutor << "/t"
			<< book[i].PrenAutor << "/t" << book[i].Titlu
			<< "/t" << book[i].AnEd << "/t" << book[i].PretC << endl;
}

#include <iostream>
#include "carti.h"

using namespace std;

int main()
{
	int ch;
	do
	{
		cout << "0-exit" << ednl;
		cout << "1-show all books" << ednl;
		cout << "2-add new book" << ednl;
		cout << "3-delete a book" << ednl;
		cout << "4-old book" << ednl;
		cout << "5-new book\n" << ednl;

		cout << "Alegerea dumneavoastra:" ;
		cin >> ch;

		switch (ch)
		{
		case 1:
		{
			readBook();
			showBook();
			break;
		}
		case 2:
		{
			readBook();
			delBook();
			break;
		}
		case 3:
		{
			readBook();
			addBook();
			break;
		}
		case 4:
		{
			readBook();
			newBook();
			break;
		}
		case 5:
		{
			readBook();
			oldBook();
			break;
		}
	} 
	while (ch!=0);

	return 1;
}
  • Вопрос задан
  • 68 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
04 апр. 2020, в 23:07
30000 руб./за проект
04 апр. 2020, в 23:05
100000 руб./за проект
04 апр. 2020, в 22:57
5000 руб./за проект