1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#define _CRT_SECURE_NO_WARNINGS
#define NAME_SIZE 40
#define size 12
using namespace std;
void fill (char names[][NAME_SIZE], int size); // function should fill array of c strings with the desired size (12)
void findName (char names[][NAME_SIZE], char lookUp[NAME_SIZE], int size); // function should accept array of c strings and search for term
int main()
{
char lookUp;
char** names;
names = new char*[NAME_SIZE];//
names[0]=new char[NAME_SIZE];//
names[1]=new char[NAME_SIZE];//
names[2]=new char[NAME_SIZE];
names[3]=new char[NAME_SIZE];
names[4]=new char[NAME_SIZE];
names[5]=new char[NAME_SIZE];
names[6]=new char[NAME_SIZE];
names[7]=new char[NAME_SIZE];
names[8]=new char[NAME_SIZE];
names[9]=new char[NAME_SIZE];
names[10]=new char[NAME_SIZE];
names[11]=new char[NAME_SIZE];
strcpy(names[0],"Brock Baur, 634-5235");
strcpy(names[1],"Bill Kerman, 705-3429");
strcpy(names[2],"Jebediah Babakazooie 563-5362");
strcpy(names[3],"John Doe 218-4351");
strcpy(names[4],"William Honk 255-2435");
strcpy(names[5],"Kevin Smith, 250-3523");
strcpy(names[6],"Sally Su, 249-3523");
strcpy(names[7],"Jack Chan, 353-3532");
strcpy(names[8],"Paul Runner, 353-3513");
strcpy(names[9],"Angie List, 395-3135");
strcpy(names[10],"Cameron Smith, 295-3523");
strcpy(names[11],"Bob Dolf, 295-3532");
cin.getline (lookUp, NAME_SIZE);
findName (names[][NAME_SIZE],lookUp[NAME_SIZE], size);
cout<<*(names+5)<<endl;
return 0;
}
void findName (char names[][NAME_SIZE], char lookUp[NAME_SIZE], int size)
{
int *ptr = NULL;
char lookup [size];
for (int i = 0; i < size; i++)
{
strstr (names [i], lookUp)
// i haven't finished this section yet, still trying to figure out how to loop the search.
|