Question
can you please fix the error in the code below to get the expected output?? ITS URGENT!!!!! #include #include #include #include #include using namespace std;
can you please fix the error in the code below to get the expected output?? ITS URGENT!!!!!
#include
using namespace std;
const int LOC_SIZE = 10; struct Weather { char location[LOC_SIZE]; int precipitation; int humidity; int wind; };
Weather getWeather(); string formatWeather(Weather);
int main() { Weather data = {};
data = getWeather();
string output = formatWeather(data);
cout
return 0; }
Weather getWeather() { Weather data = {}; string input;
getline(cin, input); stringstream ss(input);
string loc; getline(ss, loc, ','); strncpy(data.location, loc.c_str(), LOC_SIZE); data.location[LOC_SIZE - 1] = '\0';
ss >> data.precipitation >> data.humidity >> data.wind;
return data; }
string formatWeather(Weather data) { stringstream result; result
return result.str(); }
Output differs. See highlights below. Special character legend 2:Compare output 0/3 Output differs. See highlights below. Special character legend
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started