Hello. I\'m still new to C++ and I\'m in the process of learning the syntax to o
ID: 3674573 • Letter: H
Question
Hello. I'm still new to C++ and I'm in the process of learning the syntax to open files. I'm trying to extract the text and display it on the terminal (I'm using the Geany compiler), but I keep getting these errors and I'm not sure what is wrong because I've never gotten these kinds of errors before. I have the necessary #include statements such as <fstream> <string> <sstream> etc for the program.
I'd like to know where I went wrong in the code or is it possible my txt file is in the wrong location?
EX EX Symbols person.cppreadfile.cpptext.cpp x 32 Classes Person [11] cP Person [14] 34 35 int main() Person [16] birth_day [27 37 ringtnanelnane birth_month [2 birth_year [29] 36 [2 38 39 o first_name [25] 41 get birth_day 42 cPget-birth-montl 43 .wwf o get_name [17145 o last_name [26] o print [22] 46 47 2D 2D 2D 2T 2D o set_birthday_da 48 49Explanation / Answer
we will code the program in the following way to avoid errors:
int main()
{ string fname,lname;
int month,day,year;
string text;
ifstream myfile
myfile.open("preisdents.txt");
while (!myfile.eof()) {
myfile>>fname>>lname>>month>>day>>year;
cout<<fname<<lname<<month<<day<<year;
myfile.close();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.