я рыдалЪ!
clib.h
====
#ifndef__CLib__
#define__CLib__
#include <iostream.h>
class CLib{
  public:
    int number;
    char author[20];
    char title[20];
    int pages;
    int year;
   // void zagon();
    void editing();
    void adding();
    void deleting();
    void search();
    void print();
     CLib ();
      CLib (int number1, char *author1, char* title1, int pages1, int year1)
	{ number=number1;
	 *author=*author1;
	 *title=*title1;
	 pages=pages1;
	 year=year1;
	}
};
#endif
clib.cpp
===
#include <iostream.h>
#include "CLib.h"
#include <conio.h>
#include <string.h>
#include <stdio.h>
int n,NUM=0;
CLib :: CLib(){}
CLib *lb;
/*void CLib :: zagon(){
int n;
cout<<"Input the quantity";
cin>>n;
  for(int k=0;k<n;k++){
    cout << "Input the accession number\n";
    cin >> lb[k].number;
    cout << "Input the name of author\n";
    cin >> lb[k].author;
    cout << "Input the title\n";
    cin >> lb[k].title;
    cout << "Input the quantity of pages\n";
    cin >> lb[k].pages;
    cout << "Input the year of edition\n";
    cin >> lb[k].year; }
}*/
void CLib :: editing(){
clrscr();
char title[100];
int a, n=0,i=0;
cout << "I see you want to edit something. For this you should press/n ";
cout << "Input the title for editing/n";
cin >> title;
while(i<NUM){
  if(strcmp(lb[i].title,title)==0)
     cout<<lb[i].number<<lb[i].author<<lb[i].title<<lb[i].pag es<<lb[i].year;
     cout<<"/n";
n++;
i++;
break;}
 if (n==0){
cout << "Kniga otcutstvuet";
return;
}
cout<<"Input the pole for editing:/n"<<"1:number,2:author,3:title,4:pages,5:year\t\t\t&quo t;;
cin >> a;
switch (a){
  case 1:
  cout<<"\n";
  cout << "Input the new accession number\n";
  cin >> lb[i].number;
  break;
  case 2:
  cout << "Input the new author";
  cin >> lb[i].author;
  break;
  case 3:
  cout << "Input the new title";
  cin >> lb[i].title;
  break;
  case 4:
  cout << "Input the new quantity of pages";
  cin >> lb[i].pages;
  break;
  case 5:
  cout << "Input the new year of edition";
  cin >> lb[i].year;
  break;
  }
}
void CLib :: adding(){
clrscr();
  cout << "Input the accession number for adding:";
  cin >> lb[NUM].number;
  cout << "Input the author for adding:";
  cin >> lb[NUM].author;
   cout << "Input the title for adding:";
  cin >> lb[NUM].title;
   cout << "Input the quantity of pages for adding:";
  cin >> lb[NUM].pages;
   cout << "Input the year of edition for adding:";
  cin >> lb[NUM].year;
  NUM++;
}
void CLib :: print(){
  cout<<"Accession number:\t\t\t"<<lb[NUM].number<<"\n";
  cout<<"Author:\t\t\t"<<lb[NUM].author<<"\n" ;;
  cout<<"Title:\t\t\t"<<lb[NUM].title<<"\n"; 
  cout<<"Quantity of pages:\t\t\t"<<lb[NUM].pages<<"\n";
  cout<<"Year of edition:\t\t\t"<<lb[NUM].year<<"\n";
}
void CLib :: deleting(){
int n=0;
char a [100];
  cout << "Input the title you want to delete:";
  cin >> a;
  for(int i=0;i<NUM;i++){
     if(strcmp(lb[i].title,a)==0){
       cout<<"deleted:"<<lb[i].number<<lb[i].author<< lb[i].title<<lb[i].pages<<lb[i].year;
       n++;
    break;     }
     if(n==0){
     //  cout << "There is no such title";
      // return;}
      break;}
   for(n=i;n<NUM;n++)
   lb[n]=lb[n+1];
//   NUM--;
   }
}
/*void CLib :: search(){
clrscr();
char what[10];
int a,n=0,kol;
 cout<<"Input the pole for searching:\n (1:number,2:author,3:title,4:pages,5:year)\n";
 cin>>a;
 switch(a){
   case 1:
   cout<<"Input the number\n";
   cin>>kol;
   for(int i=0;i<NUM;i++)
   if(lb[i].number==kol){
     cout<<lb[i].number<<lb[i].author<<lb[i].title<<lb[i].pag es<<lb[i].year;
     cout<<"\n";
     n++;
     break;}
   if(n==0){
   cout<<"There is no such book";
   return;
   break;}
   case 2:
   cout<<"Input the author\n";
   cin>>what;
   for(i=1;i<NUM;i++)
   if(strcmp(lb[i].author,what)==0){
     cout<<lb[i].number<<lb[i].author<<lb[i].title<<lb[i].pag es<<lb[i].year;
     cout<<"\n";
     n++;
     break;}
   if(n==0){
   cout<<"There is no such book\n";
   return;
   break;}
   case 3:
   cout<<"Input the title\n";
   cin>>what;
   for(i=0;i<NUM;i++)
   if(strcmp(lb[i].title,what)==0){
     cout<<lb[i].number<<lb[i].author<<lb[i].title<<lb[i].pag es<<lb[i].year;
     cout<<"\n";
     n++;
     break;}
   if(n==0){
   cout<<"\nThere is no such book";
   return;
   break;}
   case 4:
   cout<<"\nInput the quantity of pages:";
   cin>>kol;
   for(i=0;i<NUM;i++)
   if(lb[i].pages==kol){
     cout<<lb[i].number<<lb[i].author<<lb[i].title<<lb[i].pag es<<lb[i].year;
     cout<<"\n";
     n++;
     break;}
   if(n==0){
   cout<<"\nThere is no such book";
   return;
   break;}
   case 5:
   cout<<"Input the year of edition:\n";
   cin>>kol;
   for(i=0;i<NUM;i++)
   if(lb[i].year==kol){
     cout<<lb[i].number<<lb[i].author<<lb[i].title<<lb[i].pag es<<lb[i].year;
     cout<<"\n";
     n++;
     break;}
   if(n==0){
   cout<<"\nThere is no such book";
   return;
   break;}
 }
}
*/
clibmain.cpp
===
#include <iostream.h>
#include "CLib.h"
#include <conio.h>
#include <stdio.h>
void main(){
CLib kniga[99];
int vibor=0,n=0;
while (vibor!=7){
clrscr();
  cout<<"1.Add data\n";
  cout<<"2.Delete data\n";
  cout<<"3.Print data\n";
  cout<<"4.Search data\n";
  cout<<"5.Edit data\n";
  cout<<"6.Sort data by year of edition\n";
//  cout
  cout<<"7.Exit\n";
  cout<<"Sdelayte vash vibor:";
  cin>>vibor;
  switch(vibor){
  case 1:
    clrscr();
     kniga[n].adding();
     n++;
     break;
  case 2:
  if(n!=0){
     kniga[n].deleting();
     n--;}
     else{ n++;}
     if(n==0){
       cout << "There is no such title";
       n=0;}
     break;
  case 3:
   if(n==1)
    cout<<"Thereis nothing to display";
    else{
     for(int i=0;i<n;i++)
     kniga[i].print();
     }
     getch();
     break;
  case 4:
     kniga[n].search();
     berak;
/*  case5:
     kniga.editing();
     break;
  case6:*/
      }                                          // close switch
   }                                             // close while
}                                                 // close main






    
      Ответ на:
      
          комментарий
        от Orlangoor 
  


    
      Ответ на:
      
          комментарий
        от robot12 
  



    
        Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
      
Похожие темы
- Форум [c++][switch] как юзать свитч для char *? (2009)
- Форум Проблема с деструктором класса (2002)
- Форум Класс для работы с очередью (2005)
- Форум Ошибка сегментирования (2017)
- Форум debug простенького приложения (С++) (2010)
- Форум [C] Параметры, Case (2012)
- Форум График(gnuplot) закрывается без ожидания c cin (c++ ) (2015)
- Форум «Ненормальное» сравнение переменной shn с единицей. (2010)
- Форум Segmentation fault (Core dumped) (2018)
- Форум Третий день бьюсь над сегфолтом... (2013)