文字列のベクトルで 2 部構成の名前を見つけようとしていますが、うまくいくと思っていたものがありますが、うまくいきません。イテレータを使用できません。これは私のコードです。これはより大きなプログラムの一部であり、5 つの関数を持つプログラム内の単一の関数です。
int deletenames()
{
ifstream inFile;
ofstream outFile;
string strFileName;
string strFName,strLName;
vector<string> vecStudent;
string strDFName, strDLName;
int i=0;
char line[80];
//delets a name
cout << endl<< " Enter a name to be deleted( First and Last Name):";
cin>>strDFName>>strDLName;
for(i<0;strDFName+ " "+strDLName=strFName+ " "+strLName; i++)
{
if(strDFName+ " "+strDLName=strFName+ " "+strLName)
{
vecStudent.erase;
cout << "Student Deleted";
}
}
// open output file for writing
outFile.open(strFileName.c_str());
if ( outFile.fail())
{
cout<<" Output file error! Student was not added"<<endl;
return -1;
}
//display the content of the vector
for(int i=0; i<vecStudent.size(); i++)
cout<< vecStudent[i]<<endl;
for(int i=0; i<vecStudent.size();i++)
outFile<<vecStudent[i]<<endl;
outFile.close();
return 0;
}
コンパイルに使用している Microsoft Visual Studio から次のエラー メッセージが表示されます。
main.cpp
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(78): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(64): warning C4101: 'line' : unreferenced local variable
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(105): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(108): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(90): warning C4101: 'line' : unreferenced local variable
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(132): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(135): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(122): warning C4101: 'line' : unreferenced local variable
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(158): warning C4552: '<' : operator has no effect; expected operator with side-effect
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(158): error C2451: conditional expression of type 'std::basic_string<_Elem,_Traits,_Ax>' is illegal
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(160): error C2451: conditional expression of type 'std::basic_string<_Elem,_Traits,_Ax>' is illegal
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(162): error C3867: 'std::vector<_Ty>::erase': function call missing argument list; use '&std::vector<_Ty>::erase' to create a pointer to member
1> with
1> [
1> _Ty=std::string
1> ]
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(179): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\ace\desktop\cpsc 1103 assingment 4\cpsc 1103 assingment 4\main.cpp(182): warning C4018: '<' : signed/unsigned mismatch