find a number from a given .txt

hello everyone i have been having problems with this.
i need to develop a program to check if the entered Number is in the
prerecorded data file. the Data file with 300 Numbers is already provided in a file .txt . the program should access the data file and search for a match.
i know how to search if i put the numbers in the program but i do not know how to search it from the datafile given.
please help
this is what i have so far
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int seqsearch(int a[],int key)
{
int myflag;
for (int i=0; i<300; i++)
{
if (a[i]== key)
{
myflag = 1;
break;
}
if (myflag==1)
cout << "Access Granted"<<endl;
else
cout <<"Access Denied"<< endl;
}
return myflag;
}

int myfile()
{
double ID;
// string line;
ifstream myfile("Data_IDN_300.txt");
if (!myfile.fail())
{

for (int k=0; k<300; ++k )
{
myfile >> ID;
cout << ID <<'\t'<< endl;
}
}
else
{
cout << "could not open file bye" << endl;
}
system ("pause");
return 0;
}
int main()
{
int key, i=0,flag=0, temp;

int myarray[300]={ ??????? };
cout << "enter ID Number" << endl;
cin>>key;
for (int i=0; i<300; i++)
{

if (myarray[i] == key)
{
flag = 1;
break;
}
}
if (flag==1)
cout << "number found"<<endl;
else
cout <<"sorry"<< endl;
system ("pause");
return 0;
}

i know that if a put number where the couestion mark is that would work but i want the number that are in the file given .txt
i hope u guys can help me thank you
I hate to do your homework for you but, I just did something like this, and I would like to share. Your making this harder than it needs to be. If you want a good example of this project type find /? at a command prompt.

If you want to read about this yourself, I think the links below would help.
http://www.cplusplus.com/reference/string/string/find/
http://www.cplusplus.com/doc/tutorial/files/
http://www.cplusplus.com/articles/DEN36Up4/

/* Search file for String */
/* Command String Filename */
#include <iostream>
#include <string>
#include <fstream>

using namespace std;
int main(int argc, char* argv[])
{
int offset;
string line;
ifstream InputFile;
// Check the value of argc. If not enough parameters have been passed, inform user and exit.
if (argc != 3) // Inform the user of how to use the program
{
// Add user directions here if desired
} // End if
else { // if we have enough parameters...
InputFile.open (argv[2]); // File List
if(InputFile.is_open())
{
cout << "Searching " << argv[2] << endl;
while(!InputFile.eof())
{
getline(InputFile,line);
if ((offset = line.find(argv[1], 0)) != string::npos)
{
cout << argv[1] << " found " << argv[2] << endl;
break; // If match found, this break will stop the program for searching further.
} // End if
} // End while
} // End if
InputFile.close();
}
return 0;
}
thank you
some one please reply to this thread ..

m sure its easy ..hhttp://www.cplusplus.com/forum/general/65973/
i am running short of time ~~
Topic archived. No new replies allowed.