2017-11-30 16 views
0

以下は、C++を使って構造体に保存したいデータの集合です。コンマ区切りの文字列エラーです。それはまた ' - 'を区切ります

3110,300,15500,1,2017-11-29,8835,010-9033-1234 
3110,396,530,1,2017-11-29,8835,010-9033-1234 
3110,401,450,2,2017-11-29,8835,010-9033-1234 

私は以下のヘルプを使用しました。 How to use stringstream to separate comma separated strings しかし、私は2つの問題に遭遇しました。日付は次のように保存されます。

10 

は、その代わりに、私は、文字列としてそれらの両方を保存する:として

2017 

と電話番号が保存されています。以下は

2017-11-29 
010-9033-1234 

私が作ったコードです。

while (fileIN.good()) { 
    while (getline(fileIN, lineA)) { 
     cout << lineA << endl; 
     istringstream ss(lineA); colA = 0; 
     while (getline(ss, token, ',')) { 
      if (colA = 0) { Data[rowA].price = stoi(token); cout << Data[rowA].price << endl; } 
      else if (colA = 1) { Data[rowA].goods_seq = stoi(token); cout << Data[rowA].goods_seq << endl;} 
      else if (colA = 2) { Data[rowA].goods_unit_price = stoi(token); cout << Data[rowA].goods_unit_price << endl;} 
      else if (colA = 3) { Data[rowA].ea = stoi(token); cout << Data[rowA].ea << endl;} 
      else if (colA = 4) { Data[rowA].want_date = token; cout << Data[rowA].want_date <<endl;} 
      else if (colA = 5) { Data[rowA].member_seq = stoi(token); cout << Data[rowA].member_seq << endl;} 
      else if (colA = 6) { Data[rowA].shipping_cellphone = token; cout << Data[rowA].shipping_cellphone << endl;} 
      colA++; 
     } 
     rowA++; 
    } 
} 
+2

を役に立てば幸いである必要がありますが、これはif (colA = 0)で発生==を行う必要があり、問題を解決するために比較を行うには '=='を使います。 –

+0

'-Wall'でコンパイルすると、このような問題を警告します。 –

+0

あなたはどこに置くのか少し具体的にすることができます== –

答えて

0

if (colA == 0)

が、これは

関連する問題