Adding a search function to return a social security number
<p>I have a program that takes in user input.  Once the user information is on file a .dat file  stores it.  The admin should be able to search on the user social and retrieve the social on file by searching by the social..  I was thinking of using a switch statement where they can search by social, last name, and birthdate.  </p>

<p>I had something like this but might be wrong.</p>

<pre><code>void Database:: SearchSocial(int n)
{
string searChedSoc;
char social;
ifstream socialS;
char *myfile = "database.txt";
ifstream socialS ( "database.txt", std::ios::in);
// exit if unable to open file.
if (!socialS.is_open())
{
cerr &lt;&lt; "File could not be opened" &lt;&lt; endl;
exit(1);
}

cout &lt;&lt; "Enter Scoial: ";
cin &gt;&gt; social;

        searChedSoc = chrFileName.SearchSocial(social);
        cout &lt;&lt; "The social is on file: " &lt;&lt; searChedSoc &lt;&lt; endl;
        if(social != NULL) 
            cout &lt;&lt; "This is not the correct social " &lt;&lt; posNum-&gt;SearchSocial() &lt;&lt; endl;
        else (social == searChedSoc)
            cout &lt;&lt; "The searched number is:" &lt;&lt; searChedNum &lt;&lt; endl;
        system("pause");
        system("cls");*/
</code></pre>

<p>How do you put together something like this? Is there an example or am I approaching this correctly?</p>
