Help with simulation H.R. employee data file

I am very new to C++, and I need help to make these conditions part of my code that I have created so far. I'm very stuck, so please help as soon as possible, thanks!

Assignment and Guidelines that I still need to meet:

In this assignment, you will simulate a H.R. employee data file which can
be searched for data associated with other data. For example, if you input
a name you can get an address or vice-versa etc. Accept all names regardless of case. Test for and reject all inputs containing invalid characters. Limit the uid input to 4 digits only. If an invalid input is detected, display the input and ask for a valid input. The name cannot contain any data type other than alpha characters. Likewise, the uid can only contain digits. Invalid inputs must not "crash" or "loop" the system or in any way cause the program to end.



#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;

struct customerRecords
{
int uid;
char name[100];
};

void findData(struct customerRecords db[])

{
while (true)


{
char value[100];
int uid = 0;

cout << "Enter uid or name: ";
cin >> value;

if (strcmp(value, "-1") == 0)
{
return;
}

//dig and alph are both counters
int dig = 0;
int alph= 0;

for ( int i = 0; i < strlen (value) ; i++)
{
if (isdigit(value[i])) dig++;
else if (isalpha(value[i])) alph++;
}

if (strlen(value) != dig &&
strlen(value) != alph)
{
cout << "Invalid entry, please try again: "<<endl;
continue;
}


//compare to see if it is four digits long
if (strlen (value) == 4)
//atoi will convert string to a number
{
uid = atoi (value);
}

int idx = 0;
for (idx = 0; idx < 2; idx++)
{
//if uid isn't 0, then look for uid

if (uid != 0)
{
if (uid == db[idx].uid)
{
cout << "Found user ID: ";
cout << db[idx].name << endl;
cin.get();
}
}
else if
(strcmp(value, db[idx].name)==0)
{
cout << "Found user name: ";
cout << db[idx].uid << endl;
cin.get();
}
}

}

cin.get();
}



int main()
{


struct customerRecords db[2] = { {1001, "Bob" },
{1002, "Joe" } };

findData(db);


cout << "Press return to exit" << endl;
cin.get();
return 0;
}

It might help to write the entire code yourself, not copy someone else.
Include:
1
2
3
4
5
#include <iostream>
#include <string>
#include <ctype.h>
#include <cstring>
#include <stdlib.h> 


And It'll compile, whether it works is another question.
Topic archived. No new replies allowed.