- 5

How do I do this. Rearrange the code to declare a file object and an associated file ''myfile.txt''. Write ''I can work with fil

Rearrange the code to declare a file object and an associated file ''myfile.txt''. Write ''I can work with files'' to the file if the file is open. Otherwise, print ''Something went wrong'' to the screen.

4th Dec 2019, 12:45 AM
Paul PK11461
Paul PK11461 - avatar
11 Answers
0
Hi Paul PK11461 Your question is a bit confuse, but you can do it easily if you know how to manipulate files. By the way, this seems to be a home assignement or watever and you forgot to post the associated code and in which language it is written. If it is c++, you can take a look on this: https://code.sololearn.com/czgs0L9Om9WY/?ref=app
4th Dec 2019, 7:43 PM
Mark
0
drag and drop from the options below to declare a file object and an associated file " myfile.txt", and write " i work with files " to the file if the file is open. otherwise, print " error " to the screen. ANSWER:- 1. Stream 2. If 3. Is_open
24th May 2020, 7:38 PM
Shailesh Kumar meena
Shailesh Kumar meena - avatar
0
fill in the blanks to declare "myclass'",publicly interited from class "A". _myclass: _ A{ Public: Int newmember; }; ANSWER:- 1. Class 2. Public
24th May 2020, 7:44 PM
Shailesh Kumar meena
Shailesh Kumar meena - avatar
0
drag and drop from the options below to declare a template class "myclass", with two constructors. one of the constructors takes parameter of template type and prints its value to the screen. ANSWER:- 1. Template 2. Myclass 3. Arg
24th May 2020, 7:49 PM
Shailesh Kumar meena
Shailesh Kumar meena - avatar
0
drag and drop from the options below to declare a template class "myclass", with two constructors. one of the constructors takes parameter of template type and prints its value to the screen. ANSWER:- 1. Template 2. Myclass 3. Arg
24th May 2020, 7:49 PM
Shailesh Kumar meena
Shailesh Kumar meena - avatar
0
rearrange the code to declare a template function "greater " , taking two arguments and returning the greater one. arguments are of template types T and U, respectively. ANSWER:- template <class T, class U> T greater(T a, U b) { if (a > b) { return a; } return b; }
24th May 2020, 7:57 PM
Shailesh Kumar meena
Shailesh Kumar meena - avatar
0
declare a file object and an associated file "myfile.txt", and write "I work with files" to the file if the file is open. Otherwise, print "Error" to the screen. ANSWER:- 1. Stream 2. If 3. Is_open
6th Jun 2020, 9:09 PM
Frederick John Suerte
Frederick John Suerte - avatar
0
#include <iostream> #include <> int main() { ofstream fileObj("myfile.txt"); (fileObj.()) { fileObj << "I work with files"; fileObj.close(); } else { cout << "Error" << endl; } }
21st Jul 2020, 2:42 PM
Thị Loan Trần
Thị Loan Trần - avatar
0
Rearrange the code to declare a file object and an associated file ''myfile.txt''. Write ''I can work with files'' to the file if the file is open. Otherwise, print ''Something went wrong'' to the screen. Answer: ofstream fileObj("myfile.txt"); if (fileObj.is_open()) { fileObj << "I can work with files"; } else { cout << "Something went wrong" << endl; }
22nd Sep 2020, 11:35 PM
OjeifoIduma
0
Drag and drop from the options below to declare a template function with two arguments of template type myT. The function returns the multiplication of its arguments. Answer: template <class myT> myT mult( myT a, myT b) { return a * b; }
22nd Sep 2020, 11:38 PM
OjeifoIduma
0
29 Comments Drag and drop from the options below to declare a file object and an associated file "myfile.txt", and write "I work with files" to the file if the file is open. Otherwise, print "Error" to the screen. #include <iostream> #include < > int main() { ofstream fileObj("myfile.txt"); (fileObj. ()) { fileObj << "I work with files"; fileObj.close(); } else { cout << "Error" << endl; } } answer : fstream if is_open
23rd Feb 2021, 7:37 AM
changa Hettiarachchi
changa Hettiarachchi - avatar