Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.Prompt the user for the name of an input text file 2.Read the input text file

ID: 3640372 • Letter: 1

Question

1.Prompt the user for the name of an input text file
2.Read the input text file and display a keyword index for the contents that shows the line number of the first occurrence of each unique word in the file
1.Display the keyword index
Notes:

1.You may assume that the input file contains no more than 1000 distinct words
2.A word is a sequence of non-whitspace characters delimited by whitespace, as per the C convention
1) #include <iostream>
#include <fstream>
std;
int main ()
{
char fileName[256];
cout << "Enter a file";
cin >> fileName;

ofstream myfile;
myfile.open (fileName);
myfile << "Writing this to a file. ";
myfile.close();
return 0;
}

Explanation / Answer

std; is not a statement. You meant using namespace std;

#include <iostream>
#include <fstream>

using namespace std;


int main ()
{
char fileName[256];
cout << "Enter a file";
cin >> fileName;

ofstream myfile;
myfile.open (fileName);
myfile << "Writing this to a file. ";
myfile.close();
return 0;
}