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 71 72 73 74 75 76 77 78 79
|
void CAB::Update(const string & s)
{
int blank1, blank2, blank3, blank4, count, counter2, secondname;
blank1 = blank2 = blank3 = blank4 = count = counter2 = secondname = 0;
string fn, ln, add, digits,rest, ln2, fn2;
char c[1];
//hash_table[0].Update(s);
string tmp = s;
char ary[200];
strncpy_s(ary, tmp.c_str(), s.length());
string therest = s.substr(2);
count = s.length() - 8;
int check = (int)ary[0];
check -= 48;
if (check == 3 || check == 6 || check == 7)
{
for (signed int i = 0; i < s.length() - 8; i++)
{
if (blank1 == 0)
{
ln += ary[i];
if (ary[i + 1] == ' ')
{
i++;
blank1 = 1;
}
}
else if (blank2 == 0 && blank1 == 1)
{
fn += ary[i];
if (ary[i + 1] == ' ')
{
blank2 = 1;
i++;
}
}
else if (blank2 == 1 && blank1 == 1)
{
add = add + ary[i];
counter2++;
}
}
digits = s.substr(count);
string combine = ln + " " + fn;
char hi2 = ary[2];
int hi = (int)hi2;
hi -= 65;
BST_Node *p = hash_table[hi].Search(combine);
if (p == 0)
{
cout << "\n Not found! Can not update! Did you enter last name first? Sorry!\n";
return;
}
if (check == 3)
{
p->address = add;
p->phone_number = digits;
return;
}
else if (check == 6)
{
p->address = add;
return;
}
else if (check == 7)
{
p->phone_number = digits;
return;
}
}
else if (check == 4 || check == 5 || check == 1 || check == 2)
{
//code here for if its 1,2,4,5
}
};
|