create a program that prompts the user for a file name and then provides the user with the number of word in the file. The program should then allow the user to repeatedly specify a number and show that word in the file. (Note: Do Not use an array.)
please write in bsic comments so i can more easily understand
A test plan for the program. (How would you know the program is actually working properly?)
A shell program with stub functions (Including parameters and return values). also please explain what is a shell program with stub fuctions not in the program itself. In c++ Thank you
Algorithm ::
Step1: Start
Step2: Declare the header files.
Step3: Openning the main function.
Step4: Open a file and initialize the values of line and
word.
Step5: Declare seek and tell functions for jump and count.
Step6: If c=null || c=s then increment word count.
Step7: If c=s then increment line count.
Step8: Print the lines,words and size of a file.
Step9: Close the opened file.
Step10: Stop.
Source
Code ::
// Header Files declaration
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
// Opening of main function
int main()
{
ifstream fin("abc.txt"); //open a text file with .txt
int line=1,word=1,size; //It will not count the first word and the
last line.So initial value is assigned to 1.
char c;
fin.seekg(0,ios::end); //bring the file pointer position to the end
of the file.
size=fin.tellg(); //count the number of bytes till the current
postion for file pointer.
fin.seekg(0,ios::beg); //bring the position of the file pointer to
the begining of file.
while(fin)
{
fin.get(c);
if(c==' '||c=='s')
word++;
if(c=='s')
line++;
}
cout<<"Lines :"<<line<<"sWords
:"<<word<<"sSize : "<<size<<"s";
fin.close(); //closing the open file.
return 0;
}
Output ::
/// *** Thank You ***///
Get Answers For Free
Most questions answered within 1 hours.