代码获取api天气:我选择其他城市时无法自动加载数据。 我想当我选择另一个城市时,我的数据会发生变化。
cout << "Enter your date of birth in format MM-DD-YYYY" << endl;
//cin.getline(monthChar, 10);
cin.get(monthChar, 03, '-');
cin.ignore();
cin.get(dayChar, 03, '-');
cin.ignore();
cin.get(yearChar, 05);
cout << dayChar[0];
cout << dayChar[1];
cout << monthChar[0];
cout << monthChar[1];
cout << " " << endl;
int day, month,year;
day =(dayChar[0] - 48 )* 10 +(dayChar[1] -48);
month =( monthChar[0]-48) * 10 + (monthChar[1]-48);
year =( yearChar[0] -48)* 1000 + (yearChar[1]-48) * 100 + (yearChar[2]-48) * 10 + (yearChar[3]-48);
cout << month << day << year;