After execution, I am getting following errors in Visual C++ 2015:
while (c< pos - 1)
error: identifier c undefined
clrscr();
error: identifier clrscr(); is undefined
case 6: display(head);
error: identifier display is undefined
Here is my code:
#include <iostream>
#include <conio.h>
#include <iomanip>
using namespace std;
struct library
{
char author[20], title[20], pub[20];
int price;
library *next;
};
int sum = 0;
void main()
{
clrscr();
library *head = NULL;
library *initial(void);
library *purchase(library *);
void stock(library *);
void search(library *);
int choice;
while (1)
{
cout << "Mtavari\n";
cout << "1) Sawyisi monacemebi\n";
cout << "2) Yidvebi\n";
cout << "3) Gayidvebi\n";
cout << "4) Wignebi\n";
cout << "5) Dzieba\n";
cout << "6) Wignebis nuskha\n";
cout << "7) Gamosvla\n";
cout << "Airchiet:-";
cin >> choice;
switch (choice)
{
case 1: head = initial();
getch();
break;
case 2: head = purchase(head);
getch();
break;
getch();
break;
case 5: search(head);
getch();
break;
case 6: display(head);
getch();
break;
case 7: goto out;
default: cout << "\nShecdomiti archevani\n";
}
clrscr();
}
out:
}
library *initial(void)
{
clrscr();
library *newl = NULL, *start = NULL, *end = newl;
char ch;
while (1)
{
cout << "\n\nSheiyvanet y an Y\n";
cout << "Gsurt archeva:-";
cin >> ch;
if (ch == 'y' || ch == 'Y')
{
newl = new library;
cout << "\n\nSheiyvanet wignis avtori:-";
cin >> newl->author;
cout << "Sheiyvanet satauri:-";
cin >> newl->title;
cout << "Sheiyvanet gamomcemloba:-";
cin >> newl->pub;
cout << "Sheiyvanet fasi:-";
cin >> newl->price;
sum = sum + newl->price;
if (start == NULL)
start = newl;
else
end->next = newl;
end = newl;
end->next = NULL;
}
else break;
}
return(start);
}
library *purchase(library *start)
{
clrscr();
int pos, count = 1, choice;
library *newl, *cnt = start, *head = start;
if (start == NULL)
cout << "\n\nMonacemebi ar aris\n";
cout << "\n\nMtavari\n";
cout << "1) Pirvel adgilze sheyvana\n";
cout << "2) Shuashi chamateba\n";
cout << "3) Bolo poziciaze sheyvana \n";
cout << "4) Gamosvla\n";
cout << "Airchiet:-";
cin >> choice;
if (choice >= 1 && choice <= 3)
{
newl = new library;
cout << "Avtoris saxeli :-";
cin >> newl->author;
cout << "Wignis satauri :-";
cin >> newl->title;
cout << "Gamomcemloba :-";
cin >> newl->pub;
cout << "Fasi:-";
cin >> newl->price;
sum = sum + newl->price;
}
switch (choice)
{
case 1:
newl->next = head;
head = newl;
break;
case 2:
read:
cout << "\n\nAirchiet pozicia:-";
cin >> pos;
while (cnt != NULL)
{
count++;
cnt = cnt->next;
}
if (pos<1 || pos>count + 1)
{
cout << "\n\nPozicia arasworia\n";
goto read;
}
{
while (c<pos - 1)
{
c++;
start = start->next;
}
}
newl->next = start->next;
start->next = newl;
break;
case 3:
start = start->next;
start->next = newl;
newl->next = NULL;
break;
case 4: goto out;
default: cout << "\nArchevani arasworia\n";
break;
}
out:
return(head);
}
void stock(library *start)
{
clrscr();
int count = 0;
while (start != NULL)
{
count++;
start = start->next;
}
cout << "\n\n\n\tWignebis raodenoba " << count << endl;
cout << "\tMtliani fasi " << sum;
}
void search(library *start)
{
clrscr();
char author[20], title[20];
cout << "Sheiyvanet sadziebo fraza(avtori an wigni...)\n";
cin >> title >> author;
while (start != NULL)
{
if (title == start->title)
{
if (author == start->author)
{
cout << "\n\nArsebuli wignebi\n";
cout << "Girebuleba" << start->price;
return;
}
}
}
cout << "\n\nVer moidzebna\n";
}
void display(library *start)
{
clrscr();
cout << setw(10) << "Satauri" << setw(25) << "Avtori" << setw(25) << "Publikacia" << setw(20) << "Fasi" << endl << endl;
for (int i = 0;i<40;i++)
cout << "=*";
cout << endl;
while (start != NULL)
{
cout << setw(10) << start->title << setw(25) << start->author << setw(25) << start->pub << setw(20) << start->price << endl;
start = start->next;
}
}