A simple console application that fetches and displays current weather information for a specified city using the OpenWeatherMap API.
- Fetches weather data such as temperature, humidity, and weather conditions.
- Uses C++ REST SDK (cpprestsdk) for HTTP requests and JSON parsing.
-
Clone the Repository
git clone https://github.com/yourusername/your-repository.git cd your-repository
-
Install Dependencies
Ensure you have the C++ REST SDK installed. If you are using NuGet Package Manager, install the cpprest package.
Open the NuGet Package Manager Console in Visual Studio Install-Package cpprestsdk
- Configure the Project
Open the solution file (.sln) in Visual Studio. Ensure that the project is set up to include the necessary libraries and dependencies.
- Add Your API Key
Open fetchData.cpp.
Replace "24e63da0cfa5cb0c569304f4951ea32b"
with your own OpenWeatherMap API key.
const std::string api_key = "YOUR_API_KEY_HERE";
- Build the Project
In Visual Studio, right-click on the project and select Build.
- Run the Application
After building, run the application.
Enter a city name when prompted to receive weather information.
Enter city name: London
Example Output
Enter city name: London
Temperature: 289.15 K
Humidity: 81%
Weather: Clouds
Ensure that you have a valid API key and have replaced it in fetchData.cpp. Make sure all dependencies are correctly installed and linked. If you encounter issues with missing DLLs, ensure that the DLLs for cpprestsdk are available in your executable's directory or in your system's PATH. License This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments OpenWeatherMap API for providing the weather data. C++ REST SDK for the HTTP client and JSON handling. vbnet Copy code
- Replace placeholders like
https://github.com/yourusername/your-repository.git
andYOUR_API_KEY_HERE
with your actual repository URL and API key. - Include a
LICENSE
file in your repository if you choose to license your project.
Feel free to modify or expand the README
to better fit your project's specifics and any additional details you'd like