- 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.
11 Respostas
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
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
0
fill in the blanks to declare "myclass'",publicly interited from class "A".
_myclass: _ A{
Public:
Int newmember;
};
ANSWER:-
1. Class
2. Public
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
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
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;
}
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
0
#include <iostream>
#include <>
int main() {
ofstream fileObj("myfile.txt");
(fileObj.()) {
fileObj << "I work with files";
fileObj.close();
} else {
cout << "Error" << endl;
}
}
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; }
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;
}
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