From 168276c060a9cb662fc8bfed6851b7c9e6c1fee4 Mon Sep 17 00:00:00 2001 From: Sameer <142401625+sameer6pre@users.noreply.github.com> Date: Wed, 23 Jul 2025 15:10:04 +0530 Subject: [PATCH] Update Lab_21/city_temperature_control.cpp in branch Precogs-fix-c7mqhnhu --- Lab_21/city_temperature_control.cpp | 32 ++++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Lab_21/city_temperature_control.cpp b/Lab_21/city_temperature_control.cpp index cb666d0..d23ef67 100644 --- a/Lab_21/city_temperature_control.cpp +++ b/Lab_21/city_temperature_control.cpp @@ -341,7 +341,8 @@ void CityRainFallInfo() { CityRainFall R; for (int i = 0; i < 1000; i++) { - system("cls"); + // Clear the console using a safer method + cout << "\033[2J\033[1;1H"; // ANSI escape codes for clearing the screen cout << "City RainFall Information: \n"; cout << "1. Add\n"; @@ -355,7 +356,7 @@ void CityRainFallInfo() { switch (_getch()) { case '1': { - system("cls"); + cout << "\033[2J\033[1;1H"; // Clear screen cout << "ADD DATA TO CITY\n"; cout << "Enter RainFall data of city: " << endl; // Add to List @@ -364,17 +365,19 @@ void CityRainFallInfo() { outR.write((char*)&R, sizeof(CityRainFall)); outR.close(); - system("pause"); + cout << "Press any key to continue..."; + cin.ignore(); + cin.get(); }break; case '2': { - system("cls"); + cout << "\033[2J\033[1;1H"; // Clear screen ifstream inP("R", ios::binary); while (inP.read((char*)&R, sizeof(CityRainFall))) { R.getClimateData(); } - inP.close(); // closing the files after execution + inP.close(); // searching the city by its ID int ID; @@ -412,11 +415,13 @@ void CityRainFallInfo() { out.close(); cout << "\nSuccessfully updated" << endl; - system("pause"); + cout << "Press any key to continue..."; + cin.ignore(); + cin.get(); }break; case '3': { - system("cls"); + cout << "\033[2J\033[1;1H"; // Clear screen cout << "DELETING DATA FROM CITY\n"; @@ -424,7 +429,7 @@ void CityRainFallInfo() { while (inP.read((char*)&R, sizeof(CityRainFall))) { R.getClimateData(); } - inP.close(); // closing the files after execution + inP.close(); // searching the city by its ID int ID; cout << "Enter ID of city which you want to delete: "; @@ -450,9 +455,11 @@ void CityRainFallInfo() { while (inP2.read((char*)&R, sizeof(CityRainFall))) { R.getClimateData(); } - inP2.close(); // closing the files after execution + inP2.close(); - system("pause"); + cout << "Press any key to continue..."; + cin.ignore(); + cin.get(); }break; case '0': { @@ -462,14 +469,15 @@ void CityRainFallInfo() { default: { cout << "Your choice is not available in menu!\n"; - system("pause"); + cout << "Press any key to continue..."; + cin.ignore(); + cin.get(); } break; } // switch } // for loop - } void CityHumidityInfo() {