#include #include #include using namespace std; void read_from_file() { ifstream myFile; string str, str2; int number; char letter; myFile.open("people.txt"); if (myFile.fail()) { cout << endl << "File not found!" << endl; } else { while (!myFile.eof()) { getline(myFile, str); cout << str << ", "; getline(myFile, str); number = stoi(str); cout << number << ", "; getline(myFile, str); cout << str << endl; } myFile.close(); } } void write_to_file() { ofstream outFile; float a = 4.333f; float b = 5.302f; outFile.open("calc.txt"); if (outFile.fail()) { cout << endl << "Couldn't open the file!" << endl; } else { outFile << "Ronaldo" << endl; outFile << "25" << endl; outFile << "J" << endl; outFile << "Cretino" << endl; outFile << "23" << endl; outFile << "C" << endl; outFile << "Mano dos Pano" << endl; outFile << "23" << endl; outFile << "M" << endl; outFile.close(); cout << "File written successfully!" << endl; } } int main(void) { write_to_file(); read_from_file(); // Reading a whole line from the terminal // getline(cin, str2); // cout << str2 << endl; return 0; }