Can someone help me please
I'm asked to develop a C++ program that reads a text file given by the user (e.g. test.txt), and output the frequency of the prepositions contained in the text file on the screen. The program shall provide a simple interface for the user to input the name of a text file and exit the program.
Thanks for your help.
C ++ reading text file?
code for reading the file - everything else should be easy
readFile()
{
char *myString = "";
char inFileName[] = "test.txt";
clrscr();
/* opens an existing text file for reading */
ifstream inFile = (inFileName);
if(inFile) // Input file exists and is open
{
inFile %26gt;%26gt; myString; // read an initial line
while(!inFile.eof()) // while not end of file
{
// do your stuff with myString here
// make a separate function and call it
inFile %26gt;%26gt; myString; // read a line
} // end while
inFile.close();
} // end if
// else show an error message
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment