PROBLEM 1: Copy a file to another file (create thefuntion: void writeFile (strin
ID: 3610499 • Letter: P
Question
PROBLEM 1:
Copy a file to another file (create thefuntion: void writeFile (string outStr, string filename) to doit)
Source file(input.tx) Outputfile (output.tx)
This is anapple ----> str[0] ----> This is an apple
This is abook ----> str[1] ----> This is a book
This is a cat ----> str[2] ----> This is a cat
PROBLEM 2:
Count how many times each word shows ina file (input.txt)
The content of the file looks like this:
i love you.
no, it is not true.
i really love you.
no, you are not serious =.= , i don't believe in you.
The result should be like this:
i 3
love 2
you. 3
no, 2
it 1
is 1
not 2
true. 1
really 1
you 1
are 1
serious 1
=.= 1
, 1
don't 1
believe 1
in 1
Explanation / Answer
please rate - thanks please note- cramster rules are 1 question per post #include #include #include using namespace std; void countit(string,int[],string[],int&); int main() {int count[20],i,n=0,oldpos=0; string s,words[20],word; string::size_type pos; ifstream in; in.open("text.txt"); //open file if(in.fail()) //is it ok? { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.