here is my current source code:
- Code: Select all
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
using namespace std;
int main()
{
int i, j;
string dstr;
string illegalChar[] = {"#", "@", "!", "$", "%", "?"};
cout << "enter a string" << endl;
cin >> dstr;
for (i=0;i<dstr.length();i++) {
for (j=0; j<5; j++) {
if(dstr.at(i)==illegalChar[j])//in compiler, this line was highlighted for error given below
{
dstr.replace(i, dstr.length(), "");
}
}
}
cout << dstr << endl;
system("pause");
}
my problem is that i get this error message: 18 C:\Users\Evan Rabdau\successful C++ projects\TASKMASTER360\stringsanitizer.cpp no match for 'operator==' in '(&dstr)->std::basic_string<_CharT, _Traits, _Alloc>::at [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((unsigned int)i)) == illegalChar[j]'