InterviewSolution
Saved Bookmarks
| 1. |
A text file named MATTER. TXT contains some text, which needs to be displayed such that every next character is separated by a symbol ‘#’. Write a function definition for HashDisplay() in C++ that would display the entire content of the file MATTER. TXT in the desired format.Example:If the file MATTER.TXT has the following content stored in it:THE WORLD IS ROUNDThe function HashDisplay() should display the following content:T#H#E##W#0#R#L#D##I#S# #R#0#U#N#D# |
|
Answer» void HashDisplay() { if stream fin; fin.open ("MATTER.TXT"); char ch; while(!fin.eof()) { fin.get(ch); cout<<ch<<<"#"; } fin.close(); } |
|