2012-02-12 4 views
1

私は標準の名前空間を使用していますが、ファイル名を入力するだけでプログラムはうまく動作しますが、cin VSが私に奇妙なエラーを与えます。 明確にするために、私は特にcin >> sodokuFile行について話しています。何のオペレータはタイプの「のstd :: string」の右辺のオペランドをとる見つからない(またはそこに「>>」BINARY:ここ なぜこの基本的なcinは私のプログラムのコンパイルを妨げていますか?

cout << "Assignment 2\n\n"; 
ifstream ins; 
cout << "Please enter the Sokoku file\n"; 
string sodokuFile; 
cin >> sodokuFile; 
ins.open(sodokuFile.c_str()); 

if(ins.is_open()) 
{ 
    int num; 
    //counting numbers displayed horizontally 
    int counth = 0; 
    //counting numbers displayed vertically 
    int countv = 0; 
    while (ins >> num) 
    { 
     cout << num << " "; 
     counth++; 
     //placing vertical lines 
     if(counth %3 == 0) 
     { 
      cout << "| "; 
     } 
     //making line breaks for new rows 
     if(counth == 9) 
     { 
      cout << "\n\n"; 
      counth = 0; 
      countv++; 
      //horizontal lines 
      if(countv %3 == 0) 
      { 

       cout << "_________________________________________\n"; 
      } 
     } 
    } 
} 
else 
{ 
    cout << "File does not exist\n"; 
    return 0; 
} 

return 0 ; 

は便利 エラーC2679に見えるコンパイルエラーで唯一のものです受け入れ可能な変換は stringヘッダが operator>>(istream&, string&)を宣言するので、あなたは、あなたのファイルの先頭に

#include <string> 

を配置する必要があります)

+2

##を含むでしたか? –

+1

ああ、*通常のエラーとは違った奇妙なエラー...多分それはコンパイラのバグです。これらのエラーの内容を知る方法があれば。 –

+0

最初のエラーは何ですか? –

答えて

6

ではありません。

関連する問題