#include <iostream> #include <string> #include <fstream> using namespace std;
int main()
{
cout<<"Todd Little"<<endl; cout<<"CIS326"<<endl; cout<<"Quiz#3"<<endl; cout<<"The raw data from the data file:"<<endl; cout<<"Computer Programming Book Challenging Spring C++ JAVA Winter Fall Garden GLobal/n"<<endl; cout<<" Warning BrokenJaw Book Cup_of_Tea Art Plotter Printer Mouse Cat House Shoes TV-Ad/n"<<endl; cout<<" Book BrokenCar EndlessCar EndlessSummer FullofEnergy"<<endl;
char inName[16],outName[16];
string s1,s2,s3;
s1="Search for a word:Program then checks to see if a word entered by a user is in the data"; s2="If the word is in the data then reports how many times the word is repeated in the data "; s3=s1+s2;
cout<<s3<<endl;
// with no arguments //s1=[15];
//ask user enter the input file name cout<<"enter complete imput file name(limit is 15 characters)"<<endl; cin.getline(inName,15);
//ask user enter the output file name cout<<"enter complete output file name(limit is 15 characters)"<<endl; cin.getline(outName,15);
//with argument
//open input file ifstream input(inName);
//close program if file did not open correctly if(!input) { cerr<<"\nInput file erorr!Check and run program again"; exit(1); }//end if
int count =0; string temp; while (!input.eof()) { count++; input>>temp; }
//set pointer to the beginning of the file input.clear(); input.seekg(0);
//create an array of string having the dimesion equal to the number of data string* cS = NULL; cS = new string[count];
for (int i=0;i<count;i++) { input>>cS[i]; }
cout<<"Data in the file is "<<endl;
for (int j=0;j<count;j++) { cout<<cS[j]<<endl; }
string search_word; cout<<"Enter the search word"<<endl; cin>>search_word;
for (int k=0;k<count;k++) { if (cS[k] == search_word) { cout<<"Found word " + search_word + " in file"<<endl;;
return 0; } }
cout<<"Failed to find word " + search_word + " in file"<<endl;
return 0; //To check the dynamic array, program must display the raw data direcly from the array //Program then checks to see if a word enterded by a user is in the data //Program then allows user to replace a word in the data file //Program stores the data in an output file //int main() //{ //}