I cant get the input to get the names of countries that are more than one word. I understand that it stops at the whitespace, and I would like the option to sort by alphebetical order if I want, but I can't remember how to be able to take in whitespaces for the covid19[i].country
and covid19[i].region
.
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
struct CoronaVirus
{
char country[30];
int cases;
int deaths;
char region[30];
};
int main()
{
ifstream list;
list.open("country.txt");
CoronaVirus covid19[21];
for (int i = 0;i < 20;i++)
{
list>>covid19[i].country>>covid19[i].cases>>covid19[i].deaths>>covid19[i].region;
}
for (int i = 0;i < 20;i++)
{
cout<<right<<setw(10)<<covid19[i].country<<"\t"<<right<<setw(10)<<covid19[i].cases<<"\t";
cout<<covid19[i].deaths<<"\t"<<right<<setw(10)<<covid19[i].region<<endl;
}
return 0;
}