Create an account to track your scores
and create your own practice tests:
Test: AP Computer Science A
FILE INPUT/OUTPUT
1. | Consider the following C++ code:
1. #include <iostream> 2. #include <fstream> 3. using namespace std; 4. int main() { 5. ifstream outputFile; 6. inputFile.open("TestFile.txt"); 7. outputFile << "I am writing to a file right now." << endl; 8. outputFile.close(); 9. //outputFile << "I'm writting on the file again" << endl; 10. return 0; 11. }
What is wrong with the code? |
The outputFile should be of type "ofstream", not "ifstream".
Testfile.txt shouldn't have double quotations around it.
There is nothing wrong with the code.
The ifstream library should be included.
Dolly
Certified Tutor
Certified Tutor
UTD, Bachelor of Science, Computer Science. UTD, Master of Science, Computer Science.
Milo
Certified Tutor
Certified Tutor
University of Massachusetts Amherst, Bachelor of Science, Computer Science. University of Massachusetts Amherst, Master of Sc...
Popular Subjects
LSAT Tutors in Miami, ISEE Tutors in Dallas Fort Worth, Math Tutors in Phoenix, Calculus Tutors in Phoenix, SSAT Tutors in Los Angeles, Statistics Tutors in Chicago, SAT Tutors in Miami, Math Tutors in San Francisco-Bay Area, GMAT Tutors in Philadelphia, MCAT Tutors in Denver
Popular Courses & Classes
ACT Courses & Classes in Los Angeles, ISEE Courses & Classes in Atlanta, GMAT Courses & Classes in Atlanta, ISEE Courses & Classes in Phoenix, SAT Courses & Classes in Phoenix, GMAT Courses & Classes in Boston, GMAT Courses & Classes in Philadelphia, ACT Courses & Classes in Denver, SSAT Courses & Classes in Atlanta, Spanish Courses & Classes in Houston
Popular Test Prep
ACT Test Prep in Los Angeles, LSAT Test Prep in Chicago, ISEE Test Prep in Washington DC, ACT Test Prep in Dallas Fort Worth, ISEE Test Prep in Chicago, GRE Test Prep in Philadelphia, GRE Test Prep in Dallas Fort Worth, GMAT Test Prep in Washington DC, SAT Test Prep in Dallas Fort Worth, LSAT Test Prep in Houston