Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4.  
  5. #include "Criminal.h"
  6. #include "BinaryTree.h"
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     char firstName[30];
  13.     char lastName[30];
  14.     char fullName[60];
  15.     char Crime[30];
  16.     int Months;
  17.     int counter = 0;
  18.    
  19.     Criminal* crimPtr;
  20.    
  21.     BinaryTree binarytree;
  22.     DataType datatype;
  23.    
  24.     ifstream ifs;
  25.     ifs.open("crims.txt"); // name of file is hardcoded so no error checking needed
  26.    
  27.     ifs >> firstName;  
  28.    
  29.     while(!ifs.eof())
  30.     {
  31.         ifs >> lastName;
  32.         ifs >> Crime;
  33.         ifs >> Months;
  34.    
  35.         strcat(lastName, ", ");
  36.         strcat(lastName, firstName);
  37.         strcpy(fullName, lastName);
  38.        
  39.         crimPtr = new(nothrow) Criminal(fullName, Crime, Months);
  40.        
  41.         binarytree.Insert(crimPtr);
  42.        
  43.         ifs >> firstName;
  44.     }
  45.  
  46.  
  47.    
  48.     return 0;
  49. }
  50.  
  51. int TreeDataCmp(const DataType& crim1, const DataType& crim2)
  52. {
  53.     return (crim1->compareName(*crim2));
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement