私は構造体配列にデータを読み込んでいます。データは無視しなければならない空白行で区切られています。私のコードはうまく動作しません。なぜC++は構造体への配列の読み込みに問題があります
struct Location
{
string state;
string city;
int zipcode;
}
となっています。
while (!fin.eof() && size < 50)
{
getline (fin, location[size].state);
getline (fin, location[size].city);
fin >> location[size].zipcode;
if (location[size].empty()) //to ignore blank lines but its not working?
continue;
size++;
}
それはコンパイラだろうか?
いいえ、決してコンパイラではありません。 (少なくともあなたがSOを求めている限りは) –
あなたはhte入力ファイルの内容とあなたが得るエラーを追加できますか? – Kashyap
本当のコードですか? 'Location :: empty()'はどこにも定義されていません。 – hmjd