CAWindows system321cmd.exe Enter the name of file 1: JFMAbstract.txt Enter the n
ID: 3715060 • Letter: C
Question
CAWindows system321cmd.exe Enter the name of file 1: JFMAbstract.txt Enter the name of file 2: Phys icaDAbstract.txt Press any key to continue.. . FMAbstract- Notepad File Edit Format View Hel A first-principle predictive theory for a sphere falling through sharply stratified fluid at low Reynolds number RCAMASSA, CFALCON, JLIN, RM.MCLAUGHLIN and NMYKINS A sphere exhibits a prolonged residence time when settling through a stable stratification of miscible fluids due to the deformation of the fluid-density field. PhysicaDAbstract Notepad File Edit Format View Help A conservation 1aw model for bidensity suspensions on an incline TWong, ALBertozzi The particles migrate within the fluid due to a combination of gravity-induced settling and shear induced migration. Properties Notepad File Edit Format View Help File Name: JFMAbstract.txt Number of characters:338 Number of words: 46 File Name: PhysicaDAbstract.txt Number of characters: 221 Number of words: 29 The file named "FMAbstract.txt" has less lines than "PhysicaDAbstract.txt" Figure 1: Hmw #3 sample console, input files JFMAbstract txt and PhysicaDAbstract, file "Properties.txt" and resulting outputExplanation / Answer
#include<iostream.h>
#include<fstream.h>
int main()
{
ifstream fin("NAME YOUR FILE.txt"); //opening text file
int line=1,word=1,size; //will not count first word and last line so initial value is 1
char ch;
ifstream fin1("NAME YOUT FILE.txt"); //opening text file
int line1=1,word1=1,size1; //will not count first word and last line so initial value is 1
char ch1;
fin.seekg(0,ios::end); //bring file pointer position to end of file
size=fin.tellg(); //count number of bytes till current postion for file pointer
fin1.seekg(0,ios::end); //bring file pointer position to end of file
size1=fin1.tellg(); //count number of bytes till current postion for file pointer
fin.seekg(0,ios::beg); //bring position of file pointer to begining of file
fin1.seekg(0,ios::beg); //bring position of file pointer to begining of file
while(fin)
{
fin.get(ch);
if(ch==' '||ch=='n')
word++;
if(ch=='n')
line++;
}
cout<<"Lines="<<line<<"nWords="<<word<<"nSize="<<size<<"n";
fin.close(); //closing file
while(fin1)
{
fin1.get(ch1);
if(ch1==' '||ch1=='n')
word1++;
if(ch1=='n')
line1++;
}
cout<<"Lines="<<line1<<"nWords="<<word1<<"nSize="<<size1<<"n";
fin1.close(); //closing file
if(line>line1){
cout<<"file one has more lines than file 2";
}
else
cout<<"file 2 has more words than file 1";
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.