Two Plus Two Older Archives  

Go Back   Two Plus Two Older Archives > General Gambling > Computer Technical Help
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-08-2005, 12:34 AM
mscags mscags is offline
Senior Member
 
Join Date: Mar 2005
Location: Between Two Hot Twins
Posts: 713
Default Last C++ Question for a while

I've got my program pretty much completed except for the search algorithm. I need to let the user imput a name or partial name and search for it. I also need to let the user repeat this if they want. I'm pretty sure that means I need to make the search a function that way it is easily repeated. ANyway, I have no idea how to let the user search for a name or partial name. If anyone has any ideas please let me know. Also if you see anything wrong please tell me.

//This program will let the user imput names and phone numbers and will then let

//the user search for names and will display the reults. The user will then be able

//to repeat this if they desire.

#include <iostream>

#include <string>

using namespace std;

int main()

{

char Entries = 0;

char response[13];

char Numbers = 0;

char Search;

cout << "How many entries do you have? ";

cin.getline(response,256);

Entries = atoi(response);

string *PtrNames = new string[Entries];

string *PtrNumbers = new string[Entries];

for ( int row=0; row<Entries; row++)

{

cout << "Enter name #" << row+1 << " ";

cin.getline(response,13);

PtrNames[row] = response;

}

cout << "The " << Entries << " names that you entered are " << endl;

for (int row = 0; row<Entries; row++)

{

cout << PtrNames[row] << endl;

}

for ( int row=0; row<Entries; row++)

{

cout << "Enter Phone Number #" << row+1 << " ";

cin.getline(response,13);

PtrNumbers[row] = response;

}

for (int row =0; row<Entries; row ++)
{
for (int i=0; i<1; i++)
{
if (PtrNumbers[row][i] < '0' || PtrNumbers[row][i] >'9')
{
cout << "Phone number #"<< row+1<< " is invalid\n";
cout << "Please restart this program\n";
}
else
if
(PtrNumbers[row][4] != '-' && PtrNumbers[row][7] != '-')
{
cout << "Phone number #"<<row+1<< " is invalid\n";
}

}

}

cout << "The " << Entries << " phone numbers that you entered are " << endl;

for (int row = 0; row<Entries; row++)

{
cout << PtrNumbers[row] << endl;
}

cout << "What name would you like to search for?\n";
cin >> Search; //I have no idea where to go from here

int SeeResults;
cin >> SeeResults;

return 0;

}
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.