#include <iostream>
#include <string>
#include <stdio.h>
#include <conio.h>
using namespace std;
struct DATA {
string *name;
string *pn;
string *lastname;
int *date;
int *phone;
int *cell;
};
DATA display (struct DATA *a, int i) {
printf ("First Name:\t%s\n", &a->name[i]);
printf ("Patronymic Name:\t%s\n", &a->lastname[i]);
printf ("Last Name:\t%s\n", &a->pn[i]);
printf ("Telephone:\t%i\n", &a->phone[i]);
printf ("Cell Phone:\t%i\n", &a->cell[i]);
printf ("Birthyear:\t%i\n", &a->date[i]);
}
DATA add (struct DATA *a, int number) {
printf ("\nEnter the name "); scanf ("%s", &a->name[number]);
printf ("\nEnter the last name "); scanf ("%s", &a->pn[number]);
printf ("\nEnter the patronymic name "); scanf ("%s", &a->lastname[number]);
printf ("\nEnter the telephone "); scanf ("%i", &a->phone[number]);
printf ("\nEnter the cell phone "); scanf ("%i", &a->cell[number]);
printf ("\nEnter the birthyear "); scanf ("%i", &a->date[number]);
printf ("\n The operation has been done successfully \n");
display (a, number);
}
DATA gener (struct DATA *a, int number) {
int ra;
a->name = new string[number];
a->pn = new string[number];
a->lastname = new string[number];
a->date = new int[number];
a->phone = new int[number];
a->cell = new int[number];
string fname[20]={"Marcello", "Robert", "Paul", "Steve", "Rinaldo", "Brooks", "Martin", "Anton", "Theodore", "Frederick", "Vincenzo", "Jacques", "Manuel", "James", "Mustafa"};
string pn[20]={"D'Irene", "James","Sol","John","Jaap", "Ronald","Seamus","Sergius","Klaus", "Rene", "Fabio", "Jean", "Ari", "Henry", "Serdarzade"};
string lastname[20]={"Davies","Limerik","Lee","Simons","Markovic","Marquesta","Yates","Kelly","De Vries","von Bergen","Lafayette","Duncan","Passmore","Deveraux","Acikaya"};
for(int i=0; i<number; i++) {
ra = rand()%14; a->name[i]= fname[ra];
ra = rand()%15; a->lastname[i]= lastname[ra];
ra = rand()%9; a->pn[i]= pn[ra];
ra = rand()%30+1980; a->date[i]= ra;
ra = rand()%8999999+1000000; a->phone[i]= ra;
ra = rand()%8999999+1000000; a->cell[i]= ra;
}
}
DATA sear(struct DATA *a, int by, int py, int number) {
for (int i=0; i<number; i++) {
if (a.name[i]==by) {
display (a, i);
printf ("\n=====================\n");
}
}
}
int main() {
int a=0;
int n;
char arrow;
struct DATA d;
char name[30];
int date;
int by;
printf("Input the number of people in the database ");
scanf("%i", &n);
gener(&d, n);
system("cls");
while(1) {
while(1) {
(a==0) ? printf("> ") : printf(" ");
printf("Add\n");
(a==1) ? printf("> ") : printf(" ");
printf("Search\n");
(a==2) ? printf("> ") : printf(" ");
printf("Exit\n\n");
arrow = getch();
switch(arrow) {
case 'w': a++; break;
case 's': a--; break;
default: break;
}
if (a>2) { a=0; } else if (a<0) { a=2; }
if (arrow=='y') { break; system("cls");} else {}
system("cls");
}
switch (a) {
case 0: n++; add(&d, n); break;
case 1: printf("Input the date to searching query: "); scanf("%i", &by); sear(&d, by, a, n); break;
case 2: return 0; break;
default: break;
}
}
}
В общем, выдает ошибку name is has not been declared.
В чем проблема?
Примечание:
SKYDOS идет лесом. Английский у меня proficient FYI